Start Activity From Preference Screen (intent Defined In Xml File)
set an intent filter in your activity inside manifest.xml
<activity...><intent-filter><actionandroid:name="your.action.string"/><categoryandroid:name="android.intent.category.DEFAULT" /></intent-filter></activity>
Solution 2:
try this
<intentandroid:targetPackage="your.package"android:targetClass="your.package.yourMainClassName"/>
Solution 3:
This isn't the right way to start an intent from xml. The android:action
field isn't for the name of the activity you are trying to start; it describes an action for an intent-filter (such as android.intent.action.VIEW
or android.intent.action.EDIT
) that another activity can supply.
See this answer for the correct use of <intent
>, android:action, etc: https://stackoverflow.com/a/3751306/582004
Make sure that in your AndroidManifest.xml, your activity contains an <intent-filter
> with the <action
> that you are requesting in your PreferenceActivity (in the answer referenced, this is android.intent.action.VIEW
).
Solution 4:
In your manifest :
This is the definition for your activity called [your package].MainActivity.
<activityandroid:name=".MainActivity"><intent-filter><actionandroid:name="example.action.ACTION_MAIN_ACTIVITY" /><categoryandroid:name="android.intent.category.DEFAULT" /></intent-filter></activity>
Also, try using a PreferenceScreen:
<PreferenceScreenandroid:title="@string/my_location_settings"><intentandroid:action="example.action.ACTION_MAIN_ACTIVITY"></intent></PreferenceScreen>
for more details please see this link... starting an activity from preferences.xml
Solution 5:
You should do something like this in your intent declaration inside the preference xml:
<intentandroid:targetPackage="abc.def.efg"android:targetClass="abc.def.efg.hig.yourClassName"/>
Note:targetPackage
should be same as the package
property declared inside the manifest
tag of AndroidManifest.xml
. This is confusing sometimes, so read it again.
So equivalent AndroidManifest.xml
would have declaration like this:
<manifestxmlns:android="http://schemas.android.com/apk/res/android"package="abc.def.efg"><application>
....
<activityandroid:name=".hig.yourClassName"/></application></manifest>
Post a Comment for "Start Activity From Preference Screen (intent Defined In Xml File)"