Search code examples
javaandroidimei

getImeiForSlot: The user 10170 does not meet the requirements to access device identifiers


I have android 10 I want to get IMEI below is my manifest settings

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

and below is my java code to get the IMEI but I am getting the above error.

        Button btnAuth = findViewById(R.id.button);
        TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
        btnAuth.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    Log.i("huwa ", telephonyManager.getImei());
                }catch(Exception e){
                    Log.i("huwa ", e.toString());
                }
            }
        });

Solution

  • You can't get READ_PRIVILEGED_PHONE_STATE. It's only available to privleged system apps. Unless this is a personal app and you have a rooted device so you can make your app a privleged system app.