简体   繁体   English

如何从Web应用程序导航到手机设置屏幕

[英]How to navigate to phone setting screen from a webapp

I am developing a web app using sencha touch for all mobile devices. 我正在为所有移动设备开发使用sencha touch的Web应用程序。 My application uses GPS feature. 我的应用程序使用GPS功能。 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. 我想知道如何从我的Web应用程序导航到手机的本机设置屏幕,以便用户打开GPS功能。

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. 如果GPS未开启,则会提示用户弹出窗口,将用户带到位置设置屏幕以开启GPS。

Is this possible ? 这可能吗 ?

Please let know. 请让我们知道。 I have seen this feature in many apps, even in google maps. 我已经在许多应用程序中看到了此功能,即使在Google地图中也是如此。

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. 如果您正在Phonegap或Android Web视图上运行webapp,则可以这样做。

Read this article how to bind Javascript function to Native app. 阅读本文,了解如何将Javascript函数绑定到本机应用程序。

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

Android Code Android代码

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 JavaScript代码

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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