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

Android 我想自动打开gps位置,而不向用户显示设置?,android,gps,Android,Gps,单击对话框中的“是”按钮,我想在后台自动启用GPS定位功能。怎么可能呢 Intent callGPSSettingIntent = new Intent( // android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); // ChatSDK.getSDKInstance().activity //

单击对话框中的“是”按钮,我想在后台自动启用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();
                                  }

                            }

是否可以打开gps位置?因此,您希望能够在用户不知情的情况下更改用户手机上的重要隐私设置?请检查此@RethinavelPillai,这些代码不再有效。请检查我的