我正在制作GPS安卓应用程序(用于安卓的空气)和我想要的是如果GPS关闭我想在设备上打开GPS设置或开启GPS但我不知道如何。我想在AS3中执行它或在Java中打开android设置。感谢帮助!
答案 0 :(得分:45)
您只需使用此操作启动活动:
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
我在对话框中使用它:
public static void displayPromptForEnablingGPS(final Activity activity)
{
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final String action = Settings.ACTION_LOCATION_SOURCE_SETTINGS;
final String message = "Do you want open GPS setting?";
builder.setMessage(message)
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int id) {
activity.startActivity(new Intent(action));
d.dismiss();
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int id) {
d.cancel();
}
});
builder.create().show();
}
答案 1 :(得分:5)
final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);