【问题标题】:Open specific Settings-page programmatically以编程方式打开特定的设置页面
【发布时间】:2016-12-17 18:45:43
【问题描述】:

有什么方法可以在我的应用中将用户重定向到特定设置“页面”?我的应用程序用作锁定屏幕应用程序,因此我希望能够将用户直接重定向到 Android 设置的“锁定屏幕”部分。 (最好通过按钮或类似的东西)

【问题讨论】:

标签: android android-intent android-settings


【解决方案1】:

ACTION_SECURITY_SETTINGS 意图:

 Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
 startActivity(intent);

For complete Settings Intents

【讨论】:

    【解决方案2】:

    我设法在旧的Stackoverflow-post from a while back 中找到了正确答案。现在的代码 sn-p 如下所示:

    Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
    startActivity(intent);
    

    【讨论】:

    • 不能接受我在 2 天前的回答,但这是正确的!
    【解决方案3】:
    val intent = Intent(Settings.ACTION_SECURITY_SETTINGS)
    intent.flags =
        Intent.FLAG_ACTIVITY_NEW_TASK or
        Intent.FLAG_ACTIVITY_CLEAR_TOP
    
    startActivity(intent)
    

    注意标志。这些是可选的,但如果以前打开过设置屏幕,则必须从屏幕中删除它(如果您的应用程序想要打开多个设置屏幕,则需要这样做)。

    【讨论】:

      猜你喜欢
      • 2021-07-12
      • 1970-01-01
      • 2015-11-27
      • 1970-01-01
      • 1970-01-01
      • 2014-09-14
      • 1970-01-01
      • 2011-04-08
      • 2013-10-31
      相关资源
      最近更新 更多