Android Question Get the phone number and serial number of the device

vecino

Well-Known Member
Licensed User
Longtime User
Hi, so that's it, with "new" Android versions you can't get it anymore?
Thank you very much.
 

DonManfred

Expert
Licensed User
Longtime User

Everything important is listed there

Most of the device unique ids are not exposed. Two are available:
Advertising id: https://www.b4x.com/android/forum/threads/101050/#content
Phone.GetSettings ("android_id") - https://www.b4x.com/android/forum/threads/get-unique-id-for-user.124396/#content
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
The id that is most similar to mac address, phone number, IMEI and other no longer accessible ids, is the advertising identifier. This is a global id.
So, for example, from "settings", how is the IMEI displayed?
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
It seems that in the google play store there are applications to read the phone number, the IMEI, the serial number, etc..
There must be some way to read it.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can get it with PhoneId from the Phone library, after you request the android.permission.READ_PHONE_STATE permission at runtime.

Once you see that it works, you need to:
1. Remove this permission with RemovePermission.
2. Add it with maxSdkVersion. Example here: https://www.b4x.com/android/forum/threads/runtime-permissions-android-6-0-permissions.67689/#content
3. Add the READ_PHONE_NUMBERS permission.

Request the correct permission based on Phone.SdkVersion.

 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
I'm not sure I understand the steps given, I only get errors like the one that says READ_PHONE_NUMBERS permission does not exist.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
wow!

that's exactly what i was looking for very long time
i was told it is impossible :)
glad to see it is possible - will it pass google store ?
not sure i got the idea of the permissions change - will it be possible to load a short sample?

thanks
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
I have tried several times but have not been able to get anything because I do not understand the steps to follow.
I don't know how to remove a permission that is in the manifest, or add it, from runtime code.
 
Upvote 0

Filippo

Expert
Licensed User
Longtime User
I have tried several times but have not been able to get anything because I do not understand the steps to follow.
I don't know how to remove a permission that is in the manifest, or add it, from runtime code.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
I have already tried this program, but in my case it does nothing, it does not show any message of any kind.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
In #7 you got told
There is no such answer from you. What do you expect?

Hi, DonManfred, the problem is that I don't have any code because I don't understand the steps to follow with the permissions issue.
I just don't know where to start.
Zeev Goldstein
not sure i got the idea of the permissions change - will it be possible to load a short sample?
vecino
That's my problem, I don't understand how to follow the steps.
 
Upvote 0
Top