Xamarin Forms using "android.intent.action.APPLICATION_PREFERENCES" to get gear icon intent launcher in Android Settings App Info page

3spot 96 Reputation points
2021-05-21T15:59:50.213+00:00

On Android an app can designate an activity that can be launched from the Android Settings App Info page by tapping a gear icon. This is supposedly done by setting an intent filter on the activity like so:

<activity  
  android:name="SettingsActivity"  
  android:label="@string/app_name">  
  <intent-filter>  
    <action android:name="android.intent.action.APPLICATION_PREFERENCES" />  
    <category android:name="android.intent.category.DEFAULT" />  
  </intent-filter>  
</activity>  

Are there any working examples of this with Xamarin Forms? I can't get a gear icon to ever show up in Android Settings App Info. Many other apps on the same device have them, some don't. (Android 9).

The gist of what I'm trying to do with the default hello world xamarin forms app is this:

[Activity(Label = "SysSettings", Icon = "@mipmap/icon", Theme = "@style/MainTheme"]  
[IntentFilter(new[] { "android.intent.action.APPLICATION_PREFERENCES" }, Categories = new[] { "android.intent.category.DEFAULT" })]  
public class SysActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity  
{  

This results in the android manifest getting what seems to be the right intent filter in the obj build folder, but the gear icon never shows up in Android Settings App Info.

    <activity android:configChanges="orientation|smallestScreenSize|screenLayout|screenSize|uiMode" android:icon="@mipmap/icon" android:label="SysSettings" android:theme="@style/MainTheme" android:name="crc643fbf3857e8ab79c7.SysActivity">  
      <intent-filter>  
        <action android:name="android.intent.action.APPLICATION_PREFERENCES" />  
        <category android:name="android.intent.category.DEFAULT" />  
      </intent-filter>  
    </activity>  

A working example of this would be very helpful.

Developer technologies .NET Xamarin
0 comments No comments
{count} votes

Accepted answer
  1. 3spot 96 Reputation points
    2021-05-21T18:34:56.51+00:00

    After some more digging I noticed that the above was actually working on the emulator just not the device. Then I noticed only the Samsung apps seemed to have the gear icon on this Samsung device. After digging in the manifests I found that Samsung uses this intent filter to indicate the app settings intent instead.

    	[IntentFilter(new[] { "com.sec.android.intent.action.SEC_APPLICATION_SETTINGS" }, Categories = new[] { "com.sec.android.intent.category.SEC_APPLICATION_SETTINGS" })]
    

    You can just apply both intent filters to make it work on both. Hopefully someone else finds this helpful.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.