Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
271 views
in Technique[技术] by (71.8m points)

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

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-android-secret-codes/

There are also some other codes.

Is it also possible to open this stuff programmatically?

I've tried this:

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

But it just tries to initiate a phone call and of course fails, hangs up and closes the Phone app.

EDIT: The phone *#*#4636#*#* gets saved to my Contact list as "Unknown" but the call just fails. In fact, the secret code only works when you type manually on buttons in Phone app without pressing Call in the end. Is it probably just a hidden feature of Phone app which has nothing to do with calling? If so, one could open the Phone app programmatically and simulate typing on the buttons.

According to this post Programmatically press a button in another appplication's activity

this should NOT be possible because if any app on non-rooted phone could just start other apps and press something there, it could take over control of the whole device and do bad things.

Here are some more details but I guess the post is a bit old and even if it worked it may have been changed in current Android versions: http://mylifewithandroid.blogspot.de/2009/01/generating-keypresses-programmatically.html

So, no easier way to enter secret code?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...