导出活动权限的Eclipse警告

时间:2012-11-30 03:23:51

标签: android android-manifest

我的Android清单中有这个:

   <activity
        android:name=".Planner"
        android:label="---" >
        <intent-filter>
            <action android:name="com.---.---.PLANNER" />

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

但我在Eclipse中收到警告:Exported Activity Does not Require Permission

所以我重做它是这样的:

 <activity
            android:name=".Planner"
            android:label="---" />

警告消失,但一旦启动此活动,它就会强行关闭。这是LogCat:

11-29 19:22:03.569: E/AndroidRuntime(434): FATAL EXCEPTION: main
11-29 19:22:03.569: E/AndroidRuntime(434): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.---.---.PLANNER }
11-29 19:22:03.569: E/AndroidRuntime(434):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
11-29 19:22:03.569: E/AndroidRuntime(434):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
11-29 19:22:03.569: E/AndroidRuntime(434):  at android.app.Activity.startActivityForResult(Activity.java:2827)
11-29 19:22:03.569: E/AndroidRuntime(434):  at android.app.Activity.startActivity(Activity.java:2933)
11-29 19:22:03.569: E/AndroidRuntime(434):  at com.---.---.ManageDebts$3.onClick(ManageDebts.java:135)
11-29 19:22:03.569: E/AndroidRuntime(434):  at android.view.View.performClick(View.java:2485)
11-29 19:22:03.569: E/AndroidRuntime(434):  at android.view.View$PerformClick.run(View.java:9080)
11-29 19:22:03.569: E/AndroidRuntime(434):  at android.os.Handler.handleCallback(Handler.java:587)
11-29 19:22:03.569: E/AndroidRuntime(434):  at android.os.Handler.dispatchMessage(Handler.java:92)
11-29 19:22:03.569: E/AndroidRuntime(434):  at android.os.Looper.loop(Looper.java:123)
11-29 19:22:03.569: E/AndroidRuntime(434):  at android.app.ActivityThread.main(ActivityThread.java:3683)
11-29 19:22:03.569: E/AndroidRuntime(434):  at java.lang.reflect.Method.invokeNative(Native Method)
11-29 19:22:03.569: E/AndroidRuntime(434):  at java.lang.reflect.Method.invoke(Method.java:507)
11-29 19:22:03.569: E/AndroidRuntime(434):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-29 19:22:03.569: E/AndroidRuntime(434):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-29 19:22:03.569: E/AndroidRuntime(434):  at dalvik.system.NativeStart.main(Native Method)

这是第135行:

startActivity(new Intent("com.---.---.PLANNER"));

2 个答案:

答案 0 :(得分:2)

此警告表示您在没有获得许可的情况下公开提供您的活动。

将您的清单更改为

<activity
    android:name=".Planner"
    android:label="---" 
    android:exported = "false"
>

答案 1 :(得分:1)

您需要使用不同的意图。使用

Intent intent = new Intent(YourFirstClass.this, PlannerActivity.class);
startActivity(intent);

PlannerActivity是您在Eclipse中看到的活动的名称。