Android Question GetDeviceId with Android 10 and SdkVersion 29

Sberla

Active Member
Licensed User
Longtime User
Hello everyone, compiling my app in release with android: minSdkVersion = "5" android: targetSdkVersion = "29" gives me an error that I attach.

From what I understand it's a permissions issue for the GetDeviceId method.

I entered the permissions both in the main: If Permission = rp.PERMISSION_READ_PHONE_STATE Then and in the manifest: AddPermission ("android.permission.READ_PHONE_STATE").

photo_2021-02-04_12-32-18.jpg
What else needs to be added?
 

Alex_197

Well-Known Member
Licensed User
Longtime User
Android has restricted to access for both IMEI and serial no. It is available only for platform and apps with special carrier permission. Also the permission READ_PRIVILEGED_PHONE_STATE is not available for non platform apps.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
use this instead
B4X:
Private Sub GetAdvertisingId As ResumableSub
    Dim jo As JavaObject = Me
    jo.RunMethod("GetAdvertisingId", Null)
    Wait For AdvertisingId_Ready (Success As Boolean, Id As String)
    DeviceID=Id
    Return Id
End Sub

#if Java
import java.util.concurrent.Callable;
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;

public static void GetAdvertisingId() {
   BA.runAsync(processBA, mostCurrent, "advertisingid_ready", new Object[] {false, ""}
       , new Callable<Object[]>() {
                   @Override
                   public Object[] call() throws Exception {
                       String id = AdvertisingIdClient.getAdvertisingIdInfo(mostCurrent).getId();
                       return new Object[] {true, id};
                   }
               }); }
#End If
 
Upvote 0
Top