Programmatically enter secret code like *#*#4636#*#* on Android

前端 未结 5 1001
南方客
南方客 2020-11-27 15:37

On many Android devices you can get into a secret settings menu from Phone app by typing in

*#*#4636#*#*

http://technology-headlines.com/2010/09/17/4636-and

相关标签:
5条回答
  • 2020-11-27 15:57

    looking for this

    Intent intent = new Intent("android.intent.action.MAIN");
        intent.setClassName("com.android.settings", "com.android.settings.Settings$TestingSettingsActivity");
        startActivity(intent);
    
    0 讨论(0)
  • 2020-11-27 16:10

    try this

    String ussdCode = "*" +Uri.encode ("#")+"*"+Uri.encode ("#")+ "4636" + Uri.encode ("#")+"*"+Uri.encode ("#")+"*";
    startActivity (new Intent ("android.intent.action.CALL", Uri.parse ("tel:" + ussdCode)));
    

    finally you must encode '#' using Uri.encode()

    0 讨论(0)
  • 2020-11-27 16:13

    ACTION_DIAL sends the user to the dialer with the given code (it does not call). So that would be :

    Intent intent = new Intent(Intent.ACTION_DIAL);    
    intent.setData(Uri.parse("tel:*#*#4636#*#*"));
    startActivity(intent);
    

    It would appear that codes are to be dialed, rather than to be called

    0 讨论(0)
  • 2020-11-27 16:15

    Is it also possible to open this stuff programmatically?

    Yes:

        Intent in = new Intent(Intent.ACTION_MAIN);
        in.setClassName("com.android.settings", "com.android.settings.TestingSettings");
        startActivity(in);
    

    You just need to watch logcat output to learn what this magic combination actually opens:

    I/ActivityManager(31362): START {act=android.intent.action.MAIN flg=0x10000000 cmp=com.android.settings/.TestingSettings} from pid 4257

    0 讨论(0)
  • 2020-11-27 16:16

    Secret codes exist and work independent of the dialer application. The dialer application just provides a handy interface for these codes. It recognizes the special string and then calls a special intent to invoke the action. You shouldn't use the dialer to call these dialogs. Instead you can call the secret codes directly yourself like the dialer does internally:

    Invoking built in secret codes:

    What the dialer really does when you enter the code is extracting the number between *#*# and #*#* and then broadcasting the following intent:

    sendBroadcast(new Intent("android.provider.Telephony.SECRET_CODE", Uri.parse("android_secret_code://4636")));
    

    Register your own secret codes (if you like):

    You can even register your own secret code actions using:

    <action android:name="android.provider.Telephony.SECRET_CODE" /> 
    <data android:scheme="android_secret_code" android:host="4636" /> 
    

    Source: http://android.amberfog.com/?p=422

    Edit: Fixed a bug in the original code (see comment)

    0 讨论(0)
提交回复
热议问题