• Android开发 如何快速调用系统设置


    在之前,一般我们是通过下面的方式,来调用系统设置(时间设置、网络设置等等):

    1 Intent intent = new Intent();
    2 ComponentName cn = new ComponentName("com.android.settings",
    3         "com.android.settings.WirelessSettings");
    4 intent.setComponent(cn);
    5 intent.setAction("android.intent.action.VIEW");
    6 startActivity(intent);

    但是经测试,在SDK4.0版本上使用会抛出异常,那么我们可以用下面的方式来调用系统设置界面:

      Intent intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
      startActivity(intent);

    使用下面的字段,可以在你的软件中打开相应的系统设置界面:

    android.provider.Settings.ACTION_SETTINGS                 //系统设置

    android.provider.Settings.ACTION_APN_SETTINGS         //接入点设置

    android.provider.Settings.ACTION_SOUND_SETTINGS             //声音设置

    android.provider.Settings.ACTION_WIRELESS_SETTINGS         //网络设置

    android.provider.Settings.ACTION_SECURITY_SETTINGS          //安全设置

    android.provider.Settings.ACTION_WIFI_SETTINGS                 //WiFi设置

    android.provider.Settings.ACTION_BLUETOOTH_SETTINGS      //蓝牙设置

    android.provider.Settings.ACTION_DATE_SETTINGS                //日期和时间设置

    android.provider.Settings.ACTION_BLUETOOTH_SETTINGS      //蓝牙设置

    这里只列出了常用的字段,其他的可以到官方源码中查找,是不是很简单?!

  • 相关阅读:
    LeetCode-434-字符串中的单词数
    LeetCode-415-字符串相加
    字符串
    序列
    元组
    列表
    repr()与str的区别
    输出函数print()
    输入函数input()
    MySQL中快速复制数据表方法汇总
  • 原文地址:https://www.cnblogs.com/gxchexi/p/4579642.html
Copyright © 2020-2023  润新知