android 代码打开gps,如何在Android App上以编程方式打开GPS

请帮助我在OlaCabs等移动应用中打开GPS.

我正在使用以下代码:

String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);

if(!provider.contains("gps")){ //if gps is disabled

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"));

sendBroadcast(poke);

}

但是它无法打开GPS.

解决方法:

Android准则已在4.0版以上更改.您无法以编程方式关闭高于4.0版本的GPS …

不要像我一样浪费你的时间

要使用对话框,请检查它:

或者那个:

标签:performance,android-layout,xamarin,gps,android

来源: https://codeday.me/bug/20191119/2038306.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值