美高梅4858-美高梅4858mgm-[官方网站]

Android 加了电话权限,运行还是闪退报错

AndroidManifest.xml 文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="cc.nowtime.seven">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:ignore="谷歌AppIndexingWarning">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

    <!--拨打电话权限-->
    <uses-permission android:name="android.permission.CALL_PHONE" />

    <!--拨打电话权限-->
    <uses-permission android:name="android.permission.SEND_SMS"/>

</manifest>

运行报错

D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: cc.nowtime.seven, PID: 12685
    java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxx cmp=com.android.server.telecom/.components.UserCallActivity } from ProcessRecord{e2ed078 12685:cc.nowtime.seven/u0a135} (pid=12685, uid=10135) with revoked permission android.permission.CALL_PHONE
        at android.os.Parcel.createException(Parcel.java:2071)
        at android.os.Parcel.readException(Parcel.java:2039)
        at android.os.Parcel.readException(Parcel.java:1987)
        at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:3851)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1705)
        at android.app.Activity.startActivityForResult(Activity.java:5192)
        at android.app.Activity.startActivityForResult(Activity.java:5150)
        at android.app.Activity.startActivity(Activity.java:5521)
        at android.app.Activity.startActivity(Activity.java:5489)
        at cc.nowtime.seven.MainActivity$1.onClick(MainActivity.java:36)
        at android.view.View.performClick(View.java:7125)
        at android.view.View.performClickInternal(View.java:7102)
        at android.view.View.access$3500(View.java:801)
        at android.view.View$PerformClick.run(View.java:27336)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1043)
        at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:760)
        at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:583)
        at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:1288)
        at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:514)
Process 12685 terminated.
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxx cmp=com.android.server.telecom/.components.UserCallActivity } from ProcessRecord{e2ed078 12685:cc.nowtime.seven/u0a135} (pid=12685, uid=10135) with revoked permission android.permission.CALL_PHONE

原因

你的 APP 添加拨打电话权限,但是未申请拨打电话权限,所以报错,解决办法:

  • APP 主动申请获取 拨打电话权限
  • 手动授予 拨打电话权限

主动授予拨打电话权限

  1. 打开 设置 > 应用和通知
  2. 找到你的应用
    Snipaste_2019-12-07_20-13-40.png
  3. 然后允许对应权限就可以了
    Snipaste_2019-12-07_20-14-38.png

APP 主动申请获取 拨打电话权限

自己百度 ?????

如无特别声明,该文章均为 美高梅4858官方网站NowTime.cc)原创,转载请遵循 署名-非商业性使用 4.0 国际(CC BY-NC 4.0) 协议,即转载请注明文章来源。


标签: Android, AndroidStudio

赞 (0)

添加新评论

XML 地图 | Sitemap 地图