本文介绍了如何打开Android设备的GPS设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作GPS安卓应用程序(用于安卓的机器人)和我想要的是如果GPS关闭我想在设备上打开GPS设置或开启GPS但我不知道如何。我想在AS3中执行它或在Java中打开android设置。感谢帮助!
I am making GPS android app (with air for android) and what I want is if GPS is off I want to open GPS settings on device or switch GPS on but I don't know how. I want to do it in AS3 or open android settings in Java. Thanks for help!
推荐答案
您只需使用此操作启动活动:
You can simply start an activity with this action:
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();
}
这篇关于如何打开Android设备的GPS设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!