I'm having a bit of a problem here. What I want to do is launch an Activity from within the PreferenceActivity. So my preference.xml which holds the preference layout looks like this:
<Preference android:title="Launch Activity" >
<intent android:action="org.momo.SOME_ACTIVITY" />
</Preference>
The manifest is aware of the activity I want to launch..
<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>
guess what, I'm getting a Security Exception ( Permission Denial ) when I want to launch it. Am I missing something? My understanding of intents is still a bit incomplete, yet I figured that it must work that way.
Thank you for any help!
Making an intent-filter seems like a slightly roundabout way of doing this. This is a simpler approach:
<PreferenceScreen
android:title="@string/settings.title"
android:summary="@string/settings.summary">
<intent
android:targetPackage="com.companyname.appname"
android:targetClass="com.companyname.appname.classname"/>
</PreferenceScreen>
Fully work example In your 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>
In your 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With