In my preference file I go this
<PreferenceCategory android:title="Title" >
<Preference android:title="title" >
<intent android:action="com.my.package.MainActivity"
/>
</Preference>
</PreferenceCategory>
The activity is created in the manifest file , but I still get
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.my.package.MainActivity }
How can I start activity from preferences screen ?
In Android apps, there are often settings pages that contain different options the user can tweak. The PreferenceFragment and PreferenceFragmentCompat contains a hierarchy of preference objects displayed on screen in a list. These preferences will automatically save to SharedPreferences as the user interacts with them.
Using putExtra() We can start adding data into the Intent object, we use the method defined in the Intent class putExtra() or putExtras() to store certain data as a key value pair or Bundle data object. These key-value pairs are known as Extras in the sense we are talking about Intents.
I had the same issue but none of the solutions i searched on stackoverflow solved my activitynotfound Exception.
Here is the working solution i found from here:
<PreferenceScreen
android:title="@string/title_intent_preference"
android:summary="@string/summary_intent_preference">
<intent android:action="your.action.string"/>
</PreferenceScreen>
set an intent filter in your activity inside manifest.xml
<activity ...>
<intent-filter>
<action android:name="your.action.string"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
try this
<intent android:targetPackage="your.package"
android:targetClass="your.package.yourMainClassName"/>
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