即使获得权限,getRunningTasks()也会导致错误

时间:2015-01-27 19:18:29

标签: android

Android工作室,给了我一些问题。我清楚地宣布了android。清单中的permission.GET_TASKS。但它仍然关闭了应用程序。 错误:

Caused by: java.lang.SecurityException: Permission Denial: getTasks() from pid=1010, uid=10046 requires android.permission.GET_TASKS

AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.epiclapser.noprocrastinate" >

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">
<uses-sdk
    android:maxSdkVersion="18"
    android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.GET_TASKS"/>


>
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity2"
        android:label="@string/title_activity_main_activity2"></activity>


    <activity
        android:name=".LockScreen"
        android:label="@string/title_activity_lock_screen"
        >
    </activity>

</application>

1 个答案:

答案 0 :(得分:1)

将您的权限标记移到应用程序标记之外

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="16" />

<uses-permission android:name="android.permission.GET_TASKS"/>
<application 
android:icon="@drawable/ic_launcher"
<!--Elements inside application Tag-->
</application>