简体   繁体   中英

How to navigate to phone setting screen from a webapp

I am developing a web app using sencha touch for all mobile devices. My application uses GPS feature. I would like to know how can I navigate to the native setting screen of the phone from my web app for the user to switch ON the GPS feature.

If the GPS is not ON, it will prompt user a popup which will take the user to location settings screen to turn ON the GPS.

Is this possible ?

Please let know. I have seen this feature in many apps, even in google maps.

It is not cording practice to do that. You can simply state the steps to be followed.

IF you are running webapp on Phonegap or Android web view, then you can do like this.

Read this article how to bind Javascript function to Native app.

http://developer.android.com/guide/webapps/webview.html#BindingJavaScript

Android Code

public class WebAppInterface {

    /** Show a toast from the web page */
    @JavascriptInterface
    public void goToSettingPage() {
        startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
    }

}

WebView webView = (WebView) findViewById(R.id.webview);
webView.addJavascriptInterface(new WebAppInterface(this), "Android");

JavaScript Code

<input type="button" value="Say hello" onClick="openSettingPage()" />

<script type="text/javascript">
    function openSettingPage() {
        Android.goToSettingPage();
    }
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM