【发布时间】:2017-05-16 20:10:17
【问题描述】:
我正在尝试获取 Settings.ACTION_ACCESSIBILITY_SETTINGS 或 Settings.ACTION_BATTERY_SAVER_SETTINGS 的 ApplicationInfo,以便直接启动它们。
我尝试了以下步骤,但它返回了设置的 ApplicationInfo。
private static final String[] SETTINGS_ACTION_MENUS = new String[]{
Settings.ACTION_ACCESSIBILITY_SETTINGS,Settings.ACTION_ADD_ACCOUNT};
public void getSettingPages(){
for(String menu : SETTINGS_ACTION_MENUS){
final Intent intent = new Intent(menu);
ComponentName componentName = intent.resolveActivity(packageManager);
if(componentName != null){
try {
ApplicationInfo info = packageManager.getApplicationInfo(componentName.getPackageName(),0);
if(packageManager.getLaunchIntentForPackage(info.packageName) != null){
launchableApps.add(info);
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
}
}
【问题讨论】:
标签: android android-intent android-applicationinfo