How Get The Current User ID - Java for Android App Development

I created a login system for my app, my login has a session management functionality so that user don't need to login everytime he/she uses the app. My question is how to get the current user id?
Note: The login details are fetched from a web server.

Make a table in local db for example CURRENT_USER and store there details for user session

clonedaccnt said:
.
Click to expand...
Click to collapse
panwrona said:
.
Click to expand...
Click to collapse
a database for what equates to a session token is a bit much I would think.
Maybe just issue a login token from server and store that in 'shared preferences' on the device with the expire time.

I learned so much from you deanwray. Thank you very much.

Related

Accessing Company Email

Quick question .. not sure if anyone can help or not.
My Company uses Xchange email and was wondering if there was a way to get this email pushed on to the phone first. I guess the main problem is that I am not sure if the company has pop enabled. Not really even sure what the incoming mail server and outgoing mail server are or where to find this information. Asking them really isnt an option... any thoughts?
This is the first thing that i tested with my Dopod. When it asked for servers, i just put in the web address to our Outlook Web Access site.
Hard reset after about 30 mins because my server enforced a 30min lock policy and i wasnt sure if i was allowed to hook my dopod upto the exchange server (we have strict policies about attaching non approved hardware to servers and or network)
Exchange servers don't use POP or SMTP, they use Exchange. So there are no 'incoming' or 'outgoing' mail server names.
Get your Exchange server address from your internal tech support group or your system administrator and go through the email account setup on your phone. You'll find one of the options early on is "Exchange Server".
You say that asking them for this info isn't an option, but it's the only way you're going to get this information. If you know where to look on your desktop, you can check your Outlook installation for the Exchange server name there. Otherwise, you're stuck having to ask someone.
If you just simply can't ask anyone, and can't find out on your own, it's a safe bet that your company doesn't want you to do this, and someone might get upset if you try.
i guess the real question here is. If I were to install the BBconnect 4.0 software on my phone; would this then allow me to access my company email on my Tytn?. The problem is that I am trying to get my company email on my Tytn without having to go to my corporate IT department and ask for official permission as they are idiots and say I do not have a need for this. Currently certain people have blackberry's in the company which they receive there email. From my point of view I could careless what they think I have a need for or dont. So in the end I am just trying to circumvent the IT department to achieve what I need. Any thoughts on how this could be done?
- Should also be noted that I have gone into my outlook settings on my Work PC; retrieved what is listed in there as the Microsoft Exchange server address and inputed this along with my netwrok id and password into my Tytn but when you do the Sync it does not work. I have also pinged the server address and inputed the IP# and tried that way unsucessfully as well ... any thoughts?
It's a pretty involved process. You will need to know the server addresss, user name and password and additionally an SSL certificate in order to get true push email. That's unless they use a big company like Verisign to provide SSL certificates. So you might have to talk to them...
First things first though.... Find out what the name of the exchange server is. You will also need a domain name. I'm sure you know what your username and password are.
NRGZ28 said:
It's a pretty involved process. You will need to know the server addresss, user name and password and additionally an SSL certificate in order to get true push email. That's unless they use a big company like Verisign to provide SSL certificates. So you might have to talk to them...
First things first though.... Find out what the name of the exchange server is. You will also need a domain name. I'm sure you know what your username and password are.
Click to expand...
Click to collapse
I have retrieved the domain name from going into the control panel and system icon and checked under computer name. So I know what the domain name is; I have also retrieved what is listed in the Microsoft Exchange Server address. However for some reason it still does not work; I am wondering if what is listed in the MES address field is only accessible if you are on the company internet and not an outside connection? - Thoughts?
If you retrieved that address from a computer on their internal network, than it's an "inside" address and it wont work on your phone. You need to figure out what the outside address is and it's pretty easy to do. It's usually "mail.blahblahcompanyname.com" or something like that.
Any thoughts on when the usual mail.blahblahcompanyname.com doesn't work? Any thoughts where one might find this information?
Yes. See above for my thoughts.
Pk2007 said:
Any thoughts on when the usual mail.blahblahcompanyname.com doesn't work? Any thoughts where one might find this information?
Click to expand...
Click to collapse
As mentioned by one of the posters above, the Outlook Web Access address is the best one to use to ensure that it is a valid routable host. You also mention that some of the other network users have blackberry devices. If your corporate IT guys are using Blackberry Enterprise Server, it may mean that Exchange Activesync is not enabled at the server end (or indeed that they are not using a late enough version of Exchange server) in which case, you will not be able to use it no matter what settings you have.
embeeowes said:
As mentioned by one of the posters above, the Outlook Web Access address is the best one to use to ensure that it is a valid routable host. You also mention that some of the other network users have blackberry devices. If your corporate IT guys are using Blackberry Enterprise Server, it may mean that Exchange Activesync is not enabled at the server end (or indeed that they are not using a late enough version of Exchange server) in which case, you will not be able to use it no matter what settings you have.
Click to expand...
Click to collapse
By Outlook Web Address; do you mean the website that you can visit to get your company email when you are away from the office?
Yes, try that address. Ours is https://blahblah.wahwah.com/exchange
If yours is also HTTPS you'll need the certificate. If it's a MAJOR provider like someone else posted, no worries, your device will handle it on its own. If it's a self-signed certificate, SOL.
pkley said:
Yes, try that address. Ours is https://blahblah.wahwah.com/exchange
If yours is also HTTPS you'll need the certificate. If it's a MAJOR provider like someone else posted, no worries, your device will handle it on its own. If it's a self-signed certificate, SOL.
Click to expand...
Click to collapse
Yeah I tried the web address that I login into my web mail when I am not in the office. However that does not seem to work either.
Thank you to all those who replied with useful information. Combined with the answers I received a little tinkering around; I was able to successfully accomplish what i was trying to do; which was receive company email without the involvement of the IT department.
computer misuse act
without sounding picky, you shouldnt be doing this unless you have explicit permission.
IT departments have specific policys in place to safeguard the data transmitted to mobile devices, and in this case, I doubt you know what these policies are and potentially opening up your corporate network for attack
all you have to do is call your IT department. Tell them you want to enable Outlook Mobile Access (OMA) on the server.
Once this is done, ask them for the Outlook Web Access (OWA) URL. Also, check to see if your server requires SSL or a domain (if you are unsure).
Once you're off the phone with IT, launch activesync on your ppc. press menu and choose "add server source"
enter your OWA address (without http:// or https://) and be sure to include " /exchange " without quotations at the end. press next. enter your outlook username. this is usually the same as your email before the @ symbol, however it can be different.
enter your password and then domain. ensure 'save password' is check. choose next
choose what you want to sync wirelessly , such as contacts, calendar, and task.
note: whatever you sync wirelessly will be deleted if you ever decide to stop using exchange activesycn
choose finish. the initial sync will begin. also, your company's security or it policy may force you to have a password on your phone. if so, you will be prompted during the initial sync to set up a password.
if you need any more help, let me know..

Android_MySql

Hi all,
How can i connect Android application with MySql Database
Dinesh Subramanian
dineshsubramanian said:
Hi all,
How can i connect Android application with MySql Database
Dinesh Subramanian
Click to expand...
Click to collapse
But what for? MySQL is quite big for a mobile phone.
Brut.all said:
But what for? MySQL is quite big for a mobile phone.
Click to expand...
Click to collapse
I think you miss understood him. He wants to connect to a mysql database from code, the database would be stored on a server.
I think you can get it done using MySQL Java Connector: http://www.mysql.com/downloads/connector/j/
It's quite big tho. Add the jar as asset to the project and add a reference to the library on the project properties. You should be good to go using MySQL Connector API
Thank You
Dinesh Subramanian
or you can use web services
yeedroid said:
or you can use web services
Click to expand...
Click to collapse
Yes, that's what I've done in the past. Setup a page that receives POST data from the device and the page takes care of inserting the POST data into the database. That will reduce drastically the amount of work the device needs to do locally.

how to submit in login page

How to login page use android app ?
for example u go to mail.yahoo.com and you have to write your mail and pass , i want to fetch mail.yahoo.com and fill user and pass by application and send to server.
Try this out
mehdi_shz11 said:
How to login page use android app ?
for example u go to mail.yahoo.com and you have to write your mail and pass , i want to fetch mail.yahoo.com and fill user and pass by application and send to server.
Click to expand...
Click to collapse
From what I understand from your post, you want to make a login page where you enter your email and password to be checked to see if an external database has the same credentials.
1. In your activity xml file make your edittext fields for both the email and password, also make one button field for your button.
2. In your java file, make EditText objects for both the email and password and a Button object for your button.
(E.g. EditText email = (EditText) findViewById(R.id.editTextId)
3. Follow the link in order to establish a connection to your external database. http://forum.xda-developers.com/showthread.php?t=2325799
4. Change the variables and what is checked in the guide to what you need.
Hope this helps!
mehdi_shz11 said:
How to login page use android app ?
for example u go to mail.yahoo.com and you have to write your mail and pass , i want to fetch mail.yahoo.com and fill user and pass by application and send to server.
Click to expand...
Click to collapse
I think there is no need to do that most of the web services offer a API for android applications an you may login using those !
Sent from my GT-S5302 using Tapatalk 2

android app, google playstore and hosting

hi there,
I am developing an android app and need to educate myself on how android apps are hosted.
So I read this site:
http://developer.android.com/distribute/googleplay/start.html[^]
and this site:
http://developer.android.com/distribute/tools/launch-checklist.html[^]
but my question is:
does my finished android app need to be uploaded and hosted on a server?
so when I finish developing it and am ready to deploy to google play store, do I upload my entire app on "my rented server" and then within google play store point to it?
for those of you that have uploaded apps to google play store I would really appreciate some help
another question: the android app I am developing when it opens retrieves a list of names from a database, I currently use XAMPP in which I have created a MYSQL database with a table that contains the names. When I am in my house, I can retrieve the list of names no problem using wifi or just 3g on my phone. However if I am outside and my XAMPP is turned on and then I try and open my app the listview of names is not populated.
Why is that? I am thinking its because my app is not hosted on a server itself, just the database with the names that are used in the listview grid is...
To put an app on the play store you need to upgrade your Google account to a developer account. This costs £20 if I remember correctly and allows you access to the developers console where you upload the finished app in apk format and fill out the description fields etc.
Sent from my HTC One using Tapatalk
thanks for your reply....
sure I had read what you mentioned on googles developer site.
what you are speaking about is uploading my app to google play store.
do you have any idea about these 2 questions I raise:
but my question is:
does my finished android app need to be uploaded and hosted on a server?
so when I finish developing it and am ready to deploy to google play store, do I upload my entire app on "my rented server" and then within google play store point to it?
for those of you that have uploaded apps to google play store I would really appreciate some help
another question: the android app I am developing when it opens retrieves a list of names from a database, I currently use XAMPP in which I have created a MYSQL database with a table that contains the names. When I am in my house, I can retrieve the list of names no problem using wifi or just 3g on my phone. However if I am outside and my XAMPP is turned on and then I try and open my app the listview of names is not populated.
Why is that? I am thinking its because my app is not hosted on a server itself, just the database with the names that are used in the listview grid is...
Click to expand...
Click to collapse
xirokx said:
thanks for your reply....
sure I had read what you mentioned on googles developer site.
what you are speaking about is uploading my app to google play store.
do you have any idea about these 2 questions I raise:
Click to expand...
Click to collapse
For the first question
does my finished android app need to be uploaded and hosted on a server?
Click to expand...
Click to collapse
I'm assuming that when you say server, you mean your own server? If so then no, you can use the Google developer console to upload your app, which uploads the app to Google's servers and therefore can be viewed through the play store (if you choose to put the app in a "published" mode).
Second question:
so when I finish developing it and am ready to deploy to google play store, do I upload my entire app on "my rented server" and then within google play store point to it?
Click to expand...
Click to collapse
Again, no. The only way to get apps to show up on the Play store is by getting a developer account and using the Google Play Developer Console to publish your app.
Third question:
another question: the android app I am developing when it opens retrieves a list of names from a database, I currently use XAMPP in which I have created a MYSQL database with a table that contains the names. When I am in my house, I can retrieve the list of names no problem using wifi or just 3g on my phone. However if I am outside and my XAMPP is turned on and then I try and open my app the listview of names is not populated.
Why is that? I am thinking its because my app is not hosted on a server itself, just the database with the names that are used in the listview grid is...
Click to expand...
Click to collapse
The database needs to be running on a live site for you to retrieve it from anywhere.
thank you so much for your help, i really appreciate it....
can you help clarify a little further please?
currently I use Eclipse to develop in, XAMPP to host my database and a fileserver that hosts my files.
So when I debug, is the process like this:
myPhone(includes apk file) --> XAMPP(stores names and URL) --> FileServer (Retrieves URL to display in my app)
I'm assuming that when you say server, you mean your own server? If so then no, you can use the Google developer console to upload your app, which uploads the app to Google's servers and therefore can be viewed through the play store (if you choose to put the app in a "published" mode).
Click to expand...
Click to collapse
so does the process when I upload my app to Googles Server look like this:
MyPhone ---> Google Server( to retrieve apk) --> FileServer (to retrieve URL to display in app)
have I understood correctly?
If so then no, you can use the Google developer console to upload your app, which uploads the app to Google's servers and therefore can be viewed through the play store
Click to expand...
Click to collapse
if the above process that includes google server is correct, is there a way I can upload my app to google server without releasing on play store for debugging purposes.
Currently I use XAMPP to host my database on my PC, does this mean I would need to upload XAMPP on google server so that it can retrieve the names and URL I have stored in the phpMyAdmin SQL database?
If the answer to the above is yes, does this mean I need to upload XAMPP to Google Server so it can connect to my FileServer?
The database needs to be running on a live site for you to retrieve it from anywhere.
Click to expand...
Click to collapse
So I take it using XAMPP means the database is not running on a "live site" ??
How can I host my database live? currently I start XAMPP then use:
localhost/phpmyadmin to log into my SQL database....
Do you mean I need to upload that SQL database to lets say my FileServer so it is live and therefore takes XAMPP out of the process and means I can access my APP (in debug mode) from anywhere?
So sorry I am confused about how google server, XAMPP and my SQL database work...
Thanks for your patience, please continue to help me...
Thank you so much
can anyone please kindly help?
thank you
xirokx said:
can anyone please kindly help?
thank you
Click to expand...
Click to collapse
Depends on what you plan to build
If it can work offline then you generally do not need to rent a server.
If you intent to make MMO online game, chat site, dating site, your own social networking site.. then you will need to rent a server.
Whether or not need a server for the above purposes. Your app is generally hosted on a Google Play server, and be visible to people with play-store apps (technically visible as your app is hard to search for at the beginning, this is another story)
If your app is more than 50mb.. Then you will need your own server. To host the package, containing any data in excess of 50mb. Google will host the first 50mb for you. Your users will have to go start your app to get the rest from your server.
You might want to have your own server for own custom licensing validation and IAP purchasing checks, only if you don't think the google's solution is sufficient.
You can also host on Amazon.
hotspot_volcano said:
Depends on what you plan to build
If it can work offline then you generally do not need to rent a server.
If you intent to make MMO online game, chat site, dating site, your own social networking site.. then you will need to rent a server.
Whether or not need a server for the above purposes. Your app is generally hosted on a Google Play server, and be visible to people with play-store apps (technically visible as your app is hard to search for at the beginning, this is another story)
If your app is more than 50mb.. Then you will need your own server. To host the package, containing any data in excess of 50mb. You might want to have your own server for own custom licensing validation and IAP purchasing checks, only if you don't think the google's solution is insufficient.
You can also host on Amazon.
Click to expand...
Click to collapse
Thanks for your reply
I was hoping for more specific answers in relation to my specific questions...
Well your later questions are more specifically hosting questions less about android related issues
Advice to you is to turn of wifi on your phone, when your are inside and see if you can access your XAMP server.
Can you ping your server IP address (not the local IP 192.168.0.X, assuming its your home server.
Does your ISP allow you to use your home Internet to host a server accessible on the internet? (as above)

Signin via Google+ or Facebook?

Hello,
I am developing an App that requires the user to create an account and to sign in using that account. To make it easier for the user (certainly not for me), I want the user to create his or her account using an existing Google+ or Facebook account.
So my idea was:
Sign the user into Google+ on the device
Aquire the email address and and an oauth2 access-token for the user the
send those two to my server application
validate the email using the oauth2 token by reading it from the google server
create an account on the server, storing the email and generate a "password"
send the password back to the android app to authorize future calls to my server using the email and generated password
I am not sure if this is the recommended procedure for my problem, but anyway, I am failing at the third step.
Could someone please tell me if I am on the right way or should I solve the problem in some other way?
(mods: why does it say "this is not a Q&A forum but has Q&A in the title?)
onlyolli said:
Hello,
I am developing an App that requires the user to create an account and to sign in using that account. To make it easier for the user (certainly not for me), I want the user to create his or her account using an existing Google+ or Facebook account.
So my idea was:
Sign the user into Google+ on the device
Aquire the email address and and an oauth2 access-token for the user the
send those two to my server application
validate the email using the oauth2 token by reading it from the google server
create an account on the server, storing the email and generate a "password"
send the password back to the android app to authorize future calls to my server using the email and generated password
I am not sure if this is the recommended procedure for my problem, but anyway, I am failing at the third step.
Could someone please tell me if I am on the right way or should I solve the problem in some other way?
(mods: why does it say "this is not a Q&A forum but has Q&A in the title?)
Click to expand...
Click to collapse
I assume you follow Google's guide on G+ signin? I think that is a good way to do it, but I'm not so sure about that "password" you generate on your server. Wouldn't you just use the Android device id or something like that to validate the account?
SimplicityApks said:
I assume you follow Google's guide on G+ signin? I think that is a good way to do it, but I'm not so sure about that "password" you generate on your server. Wouldn't you just use the Android device id or something like that to validate the account?
Click to expand...
Click to collapse
Thank you!
I prefered using some server secret over the android device id, cause that one is not known to other applications.
Right now i guess i have the problem that the google api is not really picking up the certificate hash and as such is not using the correct project on the api console - that would explain why i am getting "api not configured" errors and why no api access is monitored on the developer console. Maybe. -.-

Categories

Resources