简体   繁体   中英

How to check whether user is already registered or not in android application

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.

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.

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM