我想自动打开gps位置,而不向用户显示设置?

时间:2014-04-01 08:40:57

标签: android gps

我想点击对话框中的是按钮,在后台自动打开 GPS 位置启用。怎么可能?

Intent callGPSSettingIntent = new Intent(
//                                      android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
//                              ChatSDK.getSDKInstance().activity
//                                      .startActivity(callGPSSettingIntent);
                                String provider = Settings.Secure.getString(ChatSDK.getSDKInstance().activity.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
                                if(provider.contains("gps")){ // for turn on
                                    final Intent poke = new Intent();
                                    System.out.println("innnnnnnnnn");
                                    poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
                                    poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
                                    poke.setData(Uri.parse("3")); 
                                    ChatSDK.getSDKInstance().activity.sendBroadcast(poke);
                                    Toast.makeText(ChatSDK.getSDKInstance().activity, "Your GPS is Enabled",Toast.LENGTH_SHORT).show();
                                  }

                            }

0 个答案:

没有答案