Android emulators with phone numbers?

前端 未结 3 1004
Happy的楠姐
Happy的楠姐 2020-12-30 13:31

I\'m working on a client-server Android application and trying to figure out how to identify different phones/users to the server unambiguously. My first attempt would be to

3条回答
  •  暖寄归人
    2020-12-30 14:31

    The android_id is supposed to uniquely identify the device, however, it has been noted that the id can be changed if you know how Spoofing android_id

    import android.provider.Settings.System;
    
    String android_id = System.getString(this.getContentResolver(), System.ANDROID_ID);
    

    In the emulator, the android_id does not have a value, so you will need to put a debugging routine in to assign a value yourself.

    However, if you want to identify the user, and let the user access your service from different devices with one user id you are better off assigning them a user id and having them authenticate to your service using this user id as their credential. This would let them use their id's on many different devices, unless you used it in conjunction with the android_id (and the android_id wasn't spoofed) then you could limit them to one device.

提交回复
热议问题