在android中启动gps设置屏幕

时间:2011-08-11 07:29:01

标签: android

下面的代码是在三星设备中启动gps设置屏幕,但是在htc设备中它正在启动设置的安全屏幕。如何编写代码以便它将独立于设备启动gps屏幕。请帮助是否有任何替代解决方案

final ComponentName toLaunch = new ComponentName("com.android.settings","com.android.settings.SecuritySettings");
            final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            intent.setComponent(toLaunch);
            startActivity(intent);

2 个答案:

答案 0 :(得分:5)

摆脱setComponent()addCategory()来电,看看是否有帮助。在任何情况下都不应该使用它们,特别是在无效的包和类名中硬连接的ComponentName

答案 1 :(得分:-1)

我认为此代码对您有帮助

Intent intent1 = new Intent(); intent1.setClassName("com.android.settings", "com.android.settings.SecuritySettings"); context.startActivity(intent1);