Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

android - Highlighting a menu item in system settings

Trying to bring up an unaswered question I found here - How to highlight android setting app menu item?

As seen in this video https://www.youtube.com/watch?v=eHXBc5Mmsqs

The "Power Shade" menu item is being highlighted once you enter the screen. I am trying to add the same feature to my app, guiding users to an item in the settings menu using this highlight feature. I can't seem to find any information on how to actually implement this, nor do I know if it has a specific name I could search for.

Any help would be appreciated!

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

After decompiling the app, here's how it works (simplified):

Intent intent = new Intent("com.samsung.accessibility.installed_service");
if (intent.resolveActivity(context.getPackageManager()) == null) {
    intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
}
    
final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key";
final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args";
    
Bundle bundle = new Bundle();
String showArgs = context.getPackageName() + "/" + MyService.class.getName();
bundle.putString(EXTRA_FRAGMENT_ARG_KEY, showArgs);
intent.putExtra(EXTRA_FRAGMENT_ARG_KEY, showArgs);
intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, bundle);
    
try {
    context.startActivity(intent);
    String toastText = "Find PowerShade here";
    Toast.makeText(context, toastText, LENGTH_LONG).show();
} catch (Exception e) {
    // ask user to grant permission manually
}

Basically it's using undocumented features of Android (see SettingsActivity.java in Android source).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...