Android examples for Hardware:Gps
toggles a setting in the widget provider.
//package com.java2s; import android.content.Context; import android.content.Intent; import android.net.Uri; public class Main { /**//w w w .j a v a2 s. c o m * toggles a setting in the widget provider. This is a hack to bypass GPS activation restrictions and only works on older versions of Android. * * @param context * @param position */ private static void sendToggle(Context context, String position) { final Intent toggle = new Intent(); toggle.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); toggle.addCategory(Intent.CATEGORY_ALTERNATIVE); toggle.setData(Uri.parse(position)); context.sendBroadcast(toggle); } }