0

I want to launch the "dual sim settings" page from an android widget using xamarin android ui. So far I'm able to launch (for an example) DisplaySettings with

var pN=Android.Provider.Settings.ActionDisplaySettings;
var launchInt=new Intent(pN);
launchInt.AddFlags(ActivityFlags.NewTask);
context.StartActivity(launchInt);

My phone offers dual sim settings. I can even add a widget for it on the home screen. Further using the App "Shortcut Creator" I managed to create a shortcut and the information says: Action: android.intent.action.Main Flags: new_task, clear_top, receiver_foreground Component: com.android.settings/.DualCardSettings

But I have no idea how to call / launch this page.

ManniAT
  • 1,989
  • 2
  • 19
  • 25
  • Hi, here is a similar discussion for reference .https://stackoverflow.com/questions/11305407/android-dual-sim-card-api – Junior Jiang Jul 16 '19 at 06:49
  • Thank you for the hint, but I neither want to mess with the tow sims nor do I need an API - I just want to open a specific settings page from my app. In this case dual sim - but in general this could be any which has no constant in Android.Provider.Settings – ManniAT Jul 16 '19 at 06:56
  • Okey , from Android document (https://developer.android.com/reference/android/provider/Settings) , `ACTION_DATA_ROAMING_SETTINGS` maybe the best closest to the dual sim settings. – Junior Jiang Jul 16 '19 at 07:12
  • Sorry but this is not close - it is a submenu of Android.Provider.Settings.ActionWirelessSettings - so I would have to go back up to this page from the roaming - and then into the dual-sim I'm searching for. If want a close by I'd use Android.Provider.Settings.ActionWirelessSettings. But there must be a way to open dual-sim directly since "Shortcut creator" can do it also. It even lists dual-sim as a "predefined settings page". – ManniAT Jul 16 '19 at 13:19
  • Got it. However google not updating it in android document. I think this way can have a try, using adb shell to output log when entering dual-sim setting. Then this maybe can see what the package name is , so can use Intent to start package class directly. – Junior Jiang Jul 17 '19 at 01:41
  • Thank you, that sounds good - but I have no idea how to do this - could you please provide some instructions on how to do this? – ManniAT Jul 17 '19 at 08:50
  • First, need adb environment .(https://stackoverflow.com/questions/3570912/android-adb-logcat-time-filter ) Second using cmd code to log info when app running.When you enter `dual sim settings` page , you can see log activity name.(eg: wifi setting page,https://i.stack.imgur.com/HZb0l.png) .Last can start another activity(https://developer.android.com/training/basics/firstapp/starting-activity). However , if `dual sim settings` is a activity. need google expose its activity name , then can intent to it, else can not . – Junior Jiang Jul 17 '19 at 09:32
  • So if no exposed by google , then can not do that , unless you using a customed android system with exposed activity. – Junior Jiang Jul 17 '19 at 09:34
  • What I got is: 07-18 08:09:55.681 1218 1229 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[com.android.settings.SHORTCUT] flg=0x14000000 hwFlg=0x10 cmp=com.android.settings/.DualCardSettings bnds=[852,1632][1060,1941]} from uid 10087 07-18 08:09:55.681 1218 1229 I ActivityManager: ActivityRecord info: ActivityInfo{65e8a5a com.android.settings.DualCardSettings} – ManniAT Jul 18 '19 at 06:14
  • Okey, `com.android.settings/.DualCardSettings` is the activity name , you can have a try with opening by this. – Junior Jiang Jul 18 '19 at 06:20
  • I thought action is ...action.MAIN and component is ...settings/.DualCardSettings. Anyhow I have no idea how to write this in C#. Could you support me with a snippet please. – ManniAT Jul 18 '19 at 07:01
  • I have updated in answer. – Junior Jiang Jul 18 '19 at 07:32

2 Answers2

3

07-18 08:09:55.681 1218 1229 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[com.android.settings.SHORTCUT] flg=0x14000000 hwFlg=0x10 cmp=com.android.settings/.DualCardSettings bnds=[852,1632][1060,1941]} from uid 10087 07-18 08:09:55.681 1218 1229 I ActivityManager: ActivityRecord info: ActivityInfo{65e8a5a com.android.settings.DualCardSettings}

From shared log, package name is com.android.settings, com.android.settings.DualCardSettings is the activity name , if android exposed this activity, you can open it as follow way:

Intent intent = new Intent(Intent.ActionMain);
ComponentName componentName = new ComponentName("com.android.settings", "com.android.settings.DualCardSettings ");
intent.SetComponent(componentName);
StartActivity(intent);
Junior Jiang
  • 12,430
  • 1
  • 10
  • 30
0

Just in the case someone else has this (or a similar) problem I post my working code - Created with the help of @Junior Jiang - MSFT

private void StartDualCardSettings(Context pContext) {
        try {
            /*
             07-18 08:09:55.681 1218 1229 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[com.android.settings.SHORTCUT] flg=0x14000000 hwFlg=0x10 cmp=com.android.settings/.DualCardSettings bnds=[852,1632][1060,1941]} from uid 10087 
             07-18 08:09:55.681 1218 1229 I ActivityManager: ActivityRecord info: ActivityInfo{65e8a5a com.android.settings.DualCardSettings} 
            */

            var settingsIntent = new Intent("android.intent.action.MAIN");
            settingsIntent.AddCategory("com.android.settings.SHORTCUT");
            settingsIntent.SetComponent(new ComponentName("com.android.settings", "com.android.settings.DualCardSettings"));
            settingsIntent.AddFlags(ActivityFlags.NewTask);
            pContext.StartActivity(settingsIntent);
            return;

        }
        catch(Exception eX) {
            // Something went wrong :)
        }
    }

Thank you very much - works like a charm.

ManniAT
  • 1,989
  • 2
  • 19
  • 25