0

自分のアプリケーションからアクティビティを呼び出そうとし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>
4

2 に答える 2

0

私は解決策を見つけました、そしてそれをあなたと共有したいと思います。

私のようにAndroidソースを使用している場合は、packages \ apps \ settings \ scr \ com \ android \ settings\AndroidManifest.xmlにある設定マニフェストファイルでいくつかの変更を加えることができます。

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

ソースを再コンパイルして次の行でそのダイアログを呼び出すことができたら、「false」ではなくandroid:exported="true"を設定します。

Intent intent = new Intent(Intent.ACTION_RUN);
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.ChooseLockPassword"));
startActivity(intent);
于 2012-04-25T15:15:31.317 に答える
0

パーミッション拒否の例外が発生します。これは、より多くのパーミッションが必要であることを意味します。必要に応じてリストされている権限がであるということはnull、そのアクティビティをまったく呼び出すことが許可されていない可能性があることを示しています。

于 2012-04-25T13:11:44.577 に答える