2011-08-11 5 views
3

다음 코드는 삼성 장치에서 GPS 설정 화면을 시작하지만 htc 장치에서는 설정 보안 화면을 시작합니다. 어떻게 장치와 독립적으로 gps 화면을 시작할 수 있도록 코드를 작성할 수 있습니까? 제발 도움은 대체 솔루션안드로이드에서 시작 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); 

답변

5

setComponent()addCategory() 호출을 제거하고 도움이 있는지 확인하기에게 있습니다. 어쨌든 그 패키지를 사용하면 안됩니다. 특히 유효하지 않은 패키지 및 클래스 이름의 하드 와이어가있는 ComponentName을 사용해야합니다.

+0

을 위해 도움이 될 것입니다 생각! 감사. – android

+0

나를 위해 일했다 worked.thanks

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

+0

나와 함께 사용해야하는 다른 사용자를 위해 : – eWizardII

-1

는이 코드가 너무, 당신

+2

지역 설정이 약간 이동했기 때문에 JellyBean/4.1과 같은 모든 기기에서 작동하지 않습니다. –