Android 在onsen UI中打开移动GPS启用设置页面

Android 在onsen UI中打开移动GPS启用设置页面,android,gps,hybrid-mobile-app,onsen-ui,onsen-ui2,Android,Gps,Hybrid Mobile App,Onsen Ui,Onsen Ui2,我们正在OnsenUI上构建混合应用程序,并使用位置服务。与iOS本机应用程序一样,如果位置服务被禁用,onsen应用程序应显示弹出窗口,将重定向到设置->隐私页面。以便用户能够启用位置服务 我能够检测到GPS是否启用,但我无法重定向到GPS启用页面。请有人帮助我重定向Android和IOS中的设置页面 代码在下面 if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(

我们正在OnsenUI上构建混合应用程序,并使用位置服务。与iOS本机应用程序一样,如果位置服务被禁用,onsen应用程序应显示弹出窗口,将重定向到设置->隐私页面。以便用户能够启用位置服务

我能够检测到GPS是否启用,但我无法重定向到GPS启用页面。请有人帮助我重定向Android和IOS中的设置页面

代码在下面

if (navigator.geolocation)
    {

        navigator.geolocation.getCurrentPosition(

            function( position )
            {
                init(position);
                if (Location_Marker)
                {
                    return;
                }
                Location_Marker = Add_Marker(position.coords.latitude,position.coords.longitude,"Initial Position");
            },

            function( error ){
                switch(error.code)
                {
                    **case error.PERMISSION_DENIED:**
                            console.log( "Permission Denied: ", error );
                            ons.notification.alert({message:'Please Enable GPS'});
                            break;
                    **case error.POSITION_UNAVAILABLE:**
                            console.log( "POSITION_UNAVAILABLE: ", error );
                            ons.notification.confirm({message:'GPS signals are weak'});

                            break;
                }
                console.log( "Something went wrong: ", error );
                GeoLocation_Not_Supported();
            }, 

        );

    }

如果权限被拒绝,我想打开移动设置页面,以便用户可以在Android中启用GPS

,您可以使用以下方式:

 Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
 startActivityForResult(callGPSSettingIntent, 100);

我使用下面的代码片段来实现这一点

LocationManager manager;
private final int  REQUEST_CODE = 2;

manager = (LocationManager)getActivity().getSystemService( Context.LOCATION_SERVICE );

if (!manager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) {
     Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
     startActivityForResult(intent, REQUEST_CODE);
}
如果用户启用或未启用GPS,则在活动结果中,我将执行我的工作

  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(requestCode == REQUEST_CODE){
           // do your awesome stuff
        }
    }

发布您的代码,以便我们可以帮助功能(错误){switch(error.code){case error.PERMISSION\u DENIED:console.log(“PERMISSION DENIED:,error”);ons.notification.alert({消息:'Please Enable GPS'});break;case error.POSITION_UNAVAILABLE:console.log(“POSITION_UNAVAILABLE:”,error);ons.notification.confirm({消息:'GPS信号弱'});break;}地理位置不受支持(),如果权限被拒绝,那么我想打开手机的设置页面以启用GPS。请使用javascript或angular js中的代码帮助我。请使用javascript或angular js中的代码帮助我。