In Android Lollipop, when you long press a Notification, it gives you access to settings for that Notification's app, such as priority, or simply blocking it. Is there an intent that I can use to access those settings?
Found the answer here - https://plus.google.com/+CyrilMottier/posts/YY6tbJrJMra
You need to add this to the activity you want to be attached to that settings icon
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />
</intent-filter>
In addition to the correct answer from @shmuel :
In case you want this "App settings" system button to jump to one specific fragment of your app's Settings activity deriving from PreferenceActivity, you can create a dummy intermediary activity to handle the intent-filter as details above, and then in this activity you simply do:
public class DeepSettingsFragmentDummyActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent settingsIntent = new Intent(this, SettingsActivity.class);
// Standard mechanism for a PreferenceActivity intent to indicate
// which fragment to activate automatically.
settingsIntent.putExtra( PreferenceActivity.EXTRA_SHOW_FRAGMENT,
YourTargetPreferenceFragment.class.getName());
startActivity(settingsIntent);
finish();
}
}
This code automatically launches the YourTargetPreferenceFragment
fragment, and then dismisses itself (finish()
) so as to not remain in the activity stack when the user hits Back.
Your Manifest must contain:
<activity
android:name=".DeepSettingsFragmentDummyActivity"
android:label="...">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />
</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