好みの活動から起動アクティビティは、パーミッション拒否の例外が発生します
-
21-09-2019 - |
質問
私はここで少し問題を抱えています。私は何をしたいPreferenceActivity内から活動を開始しています。だから、好みのレイアウトを保持している私のpreference.xmlは次のようになります:
<Preference android:title="Launch Activity" >
<intent android:action="org.momo.SOME_ACTIVITY" />
</Preference>
マニフェストは、私が起動する活動を認識している..
<activity android:label="@string/app_name" android:name="SomeActivity">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="org.momo.SOME_ACTIVITY" />
</intent-filter>
</activity>
私はそれを起動する際に何を、私はセキュリティ例外を取得しています(パーミッション拒否)を推測します。私何か不足していますか?テントの私の理解では、まだ少し不完全で、まだ私はそれが のそのように動作しなければならないことを考え出します。
任意の助けをありがとう!
解決
インテントフィルタを作り、これを行うの少し回り道のように思えます。これは単純なアプローチです:
<PreferenceScreen
android:title="@string/settings.title"
android:summary="@string/settings.summary">
<intent
android:targetPackage="com.companyname.appname"
android:targetClass="com.companyname.appname.classname"/>
</PreferenceScreen>
他のヒント
完全に例を働きます あなたのpreference.xmlで
<Preference
android:title="@string/settings_title_notification_silent_mode"
android:summary="@string/settings_title_notification_silent_mode_summary">
<intent
android:action="com.activity.SilentModeList"/> <!-- SilentModeList its activity -->
</Preference>
あなたのmanifest.xmlで
<activity android:name="com.activity.SilentModeList"
android:label="@string/ac_settings_description">
<intent-filter>
<action android:name="com.activity.SilentModeList" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
私、私の場合、すべての私のxmlの設定が正しいことだった。
しかし、悪いrefractoringによる私が立ち上げた活動(命名AppPreferences
は)場所に存在していた:[package].AppPreferences
と[[package].commmon.Preferences
そのためimport common._
、それは活動としてこれを取っていたし、もちろん、それはAndroidのマニフェストで宣言されていませんでした。
私はちょうど私のコード出来上がりから2番目の活動を削除する必要がありました!
所属していません StackOverflow