【问题标题】:Android this app turns GPS on and offAndroid 这个应用打开和关闭 GPS
【发布时间】:2012-04-26 10:46:20
【问题描述】:

我最近在 Google Play 上看到了这个应用

https://play.google.com/store/apps/details?id=com.androidlost&hl=fr

我特别想知道它是如何做这种事情的?? (知道出于安全原因,您不能正常使用 Android SDK 进行操作...)

* start/stop GPS
* start/stop WIFI

有什么技巧可以让这成为可能吗?

谢谢

【问题讨论】:

  • 这个sdk完全支持

标签: android gps return


【解决方案1】:

有关以编程方式启用/禁用 GPS,请参阅 this 和 Wifi:

String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
final Intent poke = new Intent();
poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); 
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
 poke.setData(Uri.parse("0")); 
int wifistatus = ((WifiManager)con.getSystemService(Context.WIFI_SERVICE)).getWifiState();
if(wifistatus==1)  //if WIFI is disabled
{
sendBroadcast(poke);
}
else //if WIFI is enable
{
sendBroadcast(poke);
}

manifest.xml 权限:

<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
<uses-permission  android:name="android.permission.ACCESS_WIFI_STATE"/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多