简体   繁体   English

通过单击网站按钮打开android应用程序?

[英]Open android application by click on website button?

I have android application which contain html webpage with one single button. 我有一个包含一个按钮的html网页的android应用程序。 The html file is placed into the asset folder in android. html文件被放置在android中的asset文件夹中。 I open html file into the webview. 我将html文件打开到webview中。 Now, i what want to open the another application which is install in android device by click on the html page button. 现在,我想通过单击html页面按钮打开另一个安装在android设备中的应用程序。

Can you please anyone help me how i will do that and also give me the some reference from where i will get some help? 能否请任何人帮助我我将如何做,并从我能获得帮助的地方给我一些参考?

I think @Sk Maniruddin is asking how to open another app from a webpage. 我认为@Sk Maniruddin正在询问如何从网页打开另一个应用程序。 And the solution to that is using an intent, as the link. 解决此问题的方法是使用意图作为链接。

  <a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;end"> Take a QR code </a>

for more information you can look at the doc: https://developer.chrome.com/multidevice/android/intents#example 有关更多信息,请查看文档: https : //developer.chrome.com/multidevice/android/intents#example

Firstly set your onclik method of button in html like this. 首先像这样在html中设置按钮的onclik方法。

<input type="submit" name="submit" id="submit_id" onclick="click.performClick();" />

enable javascript your webview 启用javascript您的webview

webView.getSettings().setJavaScriptEnabled(true);

after that you can detect this click by this code: 之后,您可以通过以下代码检测到此点击:

webView.addJavascriptInterface(new Object() {
            @JavascriptInterface
            public void performClick() {// detected click 
                Intent i = new Intent(FromActivity.This, DestinationActivity.class);
                    startActivity(i);

            }

        }, "click");

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

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