0

I have made an android application.

Now in the starting screen only i want to check weather the user has already registered or not. If he is registered then he should be directed directly to contact screen and if not registered then he should be directed to Registration screen.

Main question is: -

Without taking any input from user when he/she opens his/her application can we check that user is already registered or not.

Application can be used only by 1 user per phone.

Similar example like What'sApp chatting, one app per phone. so please guide me as soon as possible.

stinepike
  • 54,068
  • 14
  • 92
  • 112
user2289532
  • 1
  • 1
  • 1
  • An idea: make a file on the phone as soon the user is registerd. Then if app starts, do a check if that file is on the phone yes or no. (yes, user is registerd. No, go to Registration screen). – Bigflow Apr 17 '13 at 07:38
  • u can use sharedpreferences to store the status – Senthil Apr 17 '13 at 07:40
  • 1
    SharedPreferences is best – Srikanth Apr 17 '13 at 07:42
  • http://stackoverflow.com/questions/4468248/unique-id-of-android-device use the unique android device id to identify the user and store it in sharedPrefrences. – Rachita Nanda Apr 17 '13 at 07:48

2 Answers2

2

First get the device unique identifier ID

final TelephonyManager tm = (TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);

    final String tmDevice, tmSerial, androidId;
    tmDevice = "" + tm.getDeviceId();
    tmSerial = "" + tm.getSimSerialNumber();
    androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);

    UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());
    String deviceId = deviceUuid.toString();

And in the manifest file:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Register it on your server database.
On start up check your server database if the unique identifier ID already registered or not.
If YES go to contact screen, if NO go to registration screen.

Lazy Ninja
  • 22,342
  • 9
  • 83
  • 103
0

I'm not able to get your question completely but there is solution from what I understood.

Use below given android ID and send it to server where it will check for this id and return response, If registered not and redirected to registration screen.

private String android_id = Secure.getString(getContext().getContentResolver(),
                                                        Secure.ANDROID_ID); 

I think this is the way to do this because if you set sharedPreferences on registration page that will not help you on another device to track that this is new device or user.

Hope this will solve your problem...

MobileEvangelist
  • 2,583
  • 1
  • 25
  • 36