从Android应用程序设置导航到相应的应用程序设置

时间:2017-02-04 05:14:48

标签: android notifications application-settings

在whatsapp应用程序中,当我们去: 设置 - >应用程序管理器 - > whatsapp - >应用信息 - >通知 有一个名为show settings或设置按钮的选项(仅限Nougat)。 单击该按钮,将加载whatsapp设置页面。

知道怎么做吗?或者是否有可用于自定义设置的文档?

3 个答案:

答案 0 :(得分:0)

我建议打开应用设置屏幕

 public static void startInstalledAppDetailsActivity(final Activity context) {
if (context == null) {
    return;
}
final Intent i = new Intent();
i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
i.addCategory(Intent.CATEGORY_DEFAULT);
i.setData(Uri.parse("package:" + context.getPackageName()));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
context.startActivity(i);

}

或试试这个

public static Intent newAppDetailsIntent(Context context, String packageName) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
    Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(Uri.parse("package:" + packageName));
    return intent;
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.FROYO) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setClassName("com.android.settings",
            "com.android.settings.InstalledAppDetails");
    intent.putExtra("pkg", packageName);
    return intent;
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName("com.android.settings",
        "com.android.settings.InstalledAppDetails");
intent.putExtra("com.android.settings.ApplicationPkgName", packageName);
return intent;
}

答案 1 :(得分:0)

尝试在您的清单文件中为您希望在设备设置中点击应用设置后显示的特定活动添加以下代码:

<intent-filter android:priority="1">
            <action android:name="android.settings.APP_NOTIFICATION_SETTINGS" />              
</intent-filter>    

答案 2 :(得分:0)

<category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />

添加具有上述类别的意图过滤器将在您的应用信息中添加设置选项&gt;通知页面。

相关问题