gpt4 book ai didi

java - 添加了读取手机状态权限但仍然崩溃

转载 作者:行者123 更新时间:2023-12-01 21:59:50 25 4
gpt4 key购买 nike

我已经在android studio的 list 中添加了读取手机状态的权限,但应用程序仍然崩溃,错误是:

9586-9586/com.tagtual.loopjexample E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.tagtual.loopjexample, PID: 9586 java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.tagtual.loopjexample/com.tagtual.loopjexample.MainActivity}: java.lang.SecurityException: getDeviceId: Neither user 10821 nor current process has android.permission.READ_PHONE_STATE.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tagtual.trackd" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<permission
android:name="com.example.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Login"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Splash"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

最佳答案

我实际上已经找到了解决方案,此问题仅在具有 Android Marshmallow 的手机中持续存在,此更新存在安全问题,用户必须手动允许应用程序将拥有的权限。转到设置->应用程序->您的应用程序->权限->启用所需的权限。不客气

关于java - 添加了读取手机状态权限但仍然崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33754042/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com