-1

このコードは私の電話では機能しましたが、友人の電話からは機能しませんでした。私にも許可があります。このエラーが発生します。

ユーザー 10109 も現在のプロセスも android.permission.READ_PHONE_STATE を持っていません。

許可 ;

    <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

これは私のコードです。

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    IMEI= telephonyManager.getDeviceId();
4

2 に答える 2

1

新しいマシュマロ os に従って、「READ_SMS」のランタイム許可を構成する必要があります。

このような :

String permission = Manifest.permission.READ_SMS;

    if (ContextCompat.checkSelfPermission(getContext(), permission) != PackageManager.PERMISSION_GRANTED){
        permissionList.add(permission);

        if (!ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), permission)){
            requestPermissions(new String[]{permission}), SMS_PERMISSION);
        }
    }
于 2016-07-18T16:27:06.630 に答える
1

This is probably due to your friend running on Android 6.0 (API level 23). You need to add permissions at Runtime as well as the ones in the Manifest.

Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app. This approach streamlines the app install process, since the user does not need to grant permissions when they install or update the app. It also gives the user more control over the app's functionality; for example, a user could choose to give a camera app access to the camera but not to the device location. The user can revoke the permissions at any time, by going to the app's Settings screen.

Refer here for more information. Maybe take a look at this question to see how to implement runtime permissions, although it's explained in the first link as well.

于 2016-07-18T16:25:59.700 に答える