Highlighting a menu item in system settings

夙愿已清 提交于 2020-08-05 08:22:50

问题


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!


回答1:


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).



来源:https://stackoverflow.com/questions/62979001/highlighting-a-menu-item-in-system-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!