简体   繁体   English

浏览器可以在用户的​​手机上启动应用程序吗?

[英]Can the browser start an application on the user's 'phone?

I am implementing a server. 我正在实施服务器。 There is no client, just the user's browser. 没有客户端,只有用户的浏览器。

For one functionality I have, until now, always redirected to a URL and let the user's browser handle it. 到目前为止,对于一种功能,我始终将其重定向到URL,并让用户的浏览器进行处理。

However, now someone wants me, as a result of user action, to "launch an app on the user's smartphone". 但是,由于用户的行为,现在有人希望我“在用户的智能手机上启动应用程序”。

Forgetting for the moment that the user might not even have the app installed, is this possible? 暂时忘记用户可能没有安装应用程序,这可能吗?

If I returned a web page with some JavaScript, would it be allowed to launch an app? 如果我返回了带有JavaScript的网页,是否可以启动应用程序? This would seem to have some security implications and I doubt that it can be done. 这似乎会带来一些安全隐患,我对此表示怀疑。

I dimly remember once reading from a PC's serial port from a web page, but I had to jump through hoops with an ActiveX control and a COM DLL to do that. 我朦胧地记得曾经从网页上从PC的串行端口读取内容,但是我不得不使用ActiveX控件和COM DLL来跳过。 Since that required Internet Explorer & Windows, it's no longer an acceptable solution. 由于需要Internet Explorer和Windows,因此它不再是可接受的解决方案。 My question pertains to all browsers and to Android & iOs (although a solution which also works for Windows, Linux & Mac would be nice to have). 我的问题涉及所有浏览器以及Android和iO(尽管有一种适用于Windows,Linux和Mac的解决方案也很不错)。

I am asking here, seeking a definitive answer. 我在这里问,寻求一个明确的答案。

I am not sure if you are talking about the default web browser or one created by you. 我不确定您是在谈论默认的Web浏览器还是您自己创建的浏览器。

Usually when you want to launch an app from a browser you have to define this in your manifest using intent filter : 通常,当您想从浏览器启动应用程序时,必须在清单中使用意图过滤器进行定义:

<intent-filter>
  <data android:scheme="http" android:host="mysite.com"/>
  <action android:name="android.intent.action.MY_ACTION" />
</intent-filter>

So if you are talking about the default browser you can not , but if it is a browser coded by you then you can start an activity like always with intents. 因此,如果您在谈论默认浏览器,则不能 ,但是,如果它是由您编码的浏览器,则可以像往常一样启动活动。

EDIT 编辑
I am not sure if this works, but try to make your links look like this and have a test: 我不确定这是否可行,但请尝试使您的链接看起来像这样并进行测试:

<a href="intent:#Intent;action=my_action;end">Link to my app</a>

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

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