gpt4 book ai didi

Android 4.1.2 如何以编程方式关闭 GPS

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:48:09 25 4
gpt4 key购买 nike

我正在尝试通过代码打开 GPS。以下是我使用过的代码。

String provider = Settings.Secure.getString(context.getContentResolver(),Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if(provider.contains("gps")){ //if gps is enabled
final Intent poke = new Intent();
poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
poke.setData(Uri.parse("3"));
context.sendBroadcast(poke);

在 OnReceive 函数中执行的代码。我做错了什么?

最佳答案

Android 准则在 4.0 版以上发生了变化。对于 4.0 以上的版本,您不能以编程方式关闭 GPS。但是,您可以通过编程方式关闭 wifi

关于Android 4.1.2 如何以编程方式关闭 GPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20048995/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com