question

3spot-9815 avatar image
0 Votes"
3spot-9815 asked RobCaplan edited

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

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.

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

3spot-9815 avatar image
0 Votes"
3spot-9815 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.