如何重定向对GPS在Android的设置窗口或使用PhoneGap的IOS上或关闭GPS [英] How to redirect towards GPS setting window in android or ios using phonegap for on or off a GPS

查看:213
本文介绍了如何重定向对GPS在Android的设置窗口或使用PhoneGap的IOS上或关闭GPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现像PhoneGap的原生Android一个功能,其中当用户想启用GPS时,透过按钮时单击它会被重定向到GPS的按钮设定的Andr​​oid或IOS的部分,以便用户可以因为编程我们不能直接开启或关闭设备上的全球定位系统,我们只能将用户重定向到设定所以如何将其重定向到PhoneGap的为Android和iOS

设置

我想实现下面的PhoneGap的功能,任何人都可以帮助我。

  / **
 *功能,以检查是否最好的网络供应商
 * @返回布尔
 * * /
公共布尔canGetLocation(){
    返回this.canGetLocation;
}

/ **
 *功能,以显示设置警告对话框
 * * /
公共无效showSettingsAlert(){
    AlertDialog.Builder alertDialog =新AlertDialog.Builder(mContext);

    //设置对话框标题
    alertDialog.setTitle(全球定位系统设置);

    //设置对话框消息
    alertDialog.setMessage(GPS未启用你想进入设置菜单。?);

    //设置图标,以对话框
    //alertDialog.setIcon(R.drawable.delete);

    //在pressing设置按钮
    alertDialog.setPositiveButton(设置,新DialogInterface.OnClickListener(){
        公共无效的onClick(DialogInterface对话,诠释它){
            意向意图=新的意图(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            mContext.startActivity(意向);
        }
    });

    //在pressing取消按钮
    alertDialog.setNegativeButton(取消,新DialogInterface.OnClickListener(){
        公共无效的onClick(DialogInterface对话,诠释它){
        dialog.cancel();
        }
    });

    //显示警报信息
    alertDialog.show();
}
 

解决方案

  startActivity(新意图(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
 

试试这个意向的朋友就带你到位置设置...

I want to implement a functionality like Native android in phonegap in which when user want to enable gps at that time via button click it will be redirected to setting section of android or IOS so that user can on the button of GPS Because programatically we can not directly on or off the GPS on the device we can only redirect the user to setting so how to redirect it to setting in phonegap for both android and IOS

I want to implement below functionality in phonegap can anyone help me.

/**
 * Function to check if best network provider
 * @return boolean
 * */
public boolean canGetLocation() {
    return this.canGetLocation;
}

/**
 * Function to show settings alert dialog
 * */
public void showSettingsAlert(){
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);

    // Setting Dialog Title
    alertDialog.setTitle("GPS is settings");

    // Setting Dialog Message
    alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");

    // Setting Icon to Dialog
    //alertDialog.setIcon(R.drawable.delete);

    // On pressing Settings button
    alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog,int which) {
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            mContext.startActivity(intent);
        }
    });

    // on pressing cancel button
    alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        dialog.cancel();
        }
    });

    // Showing Alert Message
    alertDialog.show();
}

解决方案

startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));

try this intent friend it take you to location settings...

这篇关于如何重定向对GPS在Android的设置窗口或使用PhoneGap的IOS上或关闭GPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆