2012-04-25 125 views
0

我想打電話給我自己的應用程序ChooseLockPassword活動,但發生異常。無法調用com.android.settings.ChooseLockPassword活動

Java代碼:

Intent intent = new Intent(Intent.ACTION_RUN); 
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.ChooseLockPassword")); 
startActivity(intent); 

Android清單

<!-- Lock Screen. --> 
<activity android:name="ChooseLockPassword" 
      android:exported="true"> 

<action android:name="android.intent.action.RUN" /> 

</activity> 

異常

04-25 17:54:48.599: E/AndroidRuntime(6739): FATAL EXCEPTION: main 
04-25 17:54:48.599: E/AndroidRuntime(6739): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.SystemPIN/com.test.SystemPIN.SystemPINTestActivity}: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.RUN cmp=com.android.settings/.ChooseLockPassword } from ProcessRecord{40652e98 6739:com.test.SystemPIN/10033} (pid=6739, uid=10033) requires null 
04-25 17:54:48.599: E/AndroidRuntime(6739):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 
04-25 17:54:48.599: E/AndroidRuntime(6739):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 
04-25 17:54:48.599: E/AndroidRuntime(6739):  at android.app.ActivityThread.access$1500(ActivityThread.java:117) 
04-25 17:54:48.599: E/AndroidRuntime(6739):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 
04-25 17:54:48.599: E/AndroidRuntime(6739):  at android.os.Handler.dispatchMessage(Handler.java:99) 
04-25 17:54:48.599: E/AndroidRuntime(6739):  at android.os.Looper.loop(Looper.java:123) 
04-25 17:54:48.599: E/AndroidRuntime(6739):  at android.app.ActivityThread.main(ActivityThread.java:3683) 

<snip> 

04-25 17:54:48.599: E/AndroidRuntime(6739): Caused by: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.RUN cmp=com.android.settings/.ChooseLockPassword } from ProcessRecord{40652e98 6739:com.test.SystemPIN/10033} (pid=6739, uid=10033) requires null 
04-25 17:54:48.599: E/AndroidRuntime(6739):  at android.os.Parcel.readException(Parcel.java:1322) 
04-25 17:54:48.599: E/AndroidRuntime(6739):  at android.os.Parcel.readException(Parcel.java:1276) 
04-25 17:54:48.599: E/AndroidRuntime(6739):  at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1351) 

<snip> 
+0

你的日誌格式是真正Ø FF。我已經重新格式化了一些... – 2012-04-25 13:19:25

回答

0

我找到了解決方案,並希望與大家分享。

,假如你有我,你可以只是做在設置一些修改其位於包清單文件\ APPS \設置的Android源\ SCR \ COM \機器人\設置\ AndroidManifest.xml中只需修改

<activity android:name="ChooseLockPassword" android:exported="false" 
      android:windowSoftInputMode="stateVisible|adjustResize"/> 

線,並設置機器人:出口=「真」,而不是「假」之後,你可以重新編譯源和調用對話與以下行

Intent intent = new Intent(Intent.ACTION_RUN); 
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.ChooseLockPassword")); 
startActivity(intent); 
0

你得到拒絕異常的權限,這意味着你需要更多的權限。根據需要列出的許可是null,表明您可能根本不被允許調用該活動。

+0

沒辦法做到這一點? :( – 2012-04-25 13:19:07

+0

@ViToBrothersApoyan:安全錯誤的具體味道意味着活動不會被導出,所以它不能被使用,除非被它自己的應用程序使用。 – CommonsWare 2012-04-25 13:29:04

+0

@CommonsWare我怎樣才能導出這個活動? – 2012-04-25 13:30:38