谁能指导我如何从android浏览器启动我的android应用程序?


当前回答

是的,Chrome搜索而不是寻找方案。如果你想通过URI方案启动你的应用程序,使用Play商店上的这个很酷的实用程序。它拯救了我的一天:) https://play.google.com/store/apps/details?id=com.naosim.urlschemesender

其他回答

Felix处理深度链接的方法是处理深度链接的典型方法。我还建议您查看这个库来处理深层链接的路由和解析:

https://github.com/airbnb/DeepLinkDispatch

您可以使用注释为特定的深链接URI注册Activity,它将为您提取参数,而不必执行获取路径段、匹配它等通常的繁琐操作。你可以像这样简单地注释和活动:

@DeepLink("somePath/{someParameter1}/{someParameter2}")
public class MainActivity extends Activity {
   ...
}

下面的链接给出了直接从浏览器启动应用程序(如果已安装)的信息。否则它会直接在游戏商店中打开应用程序,以便用户可以无缝下载。

https://developer.chrome.com/multidevice/android/intents

截至2014年1月28日,以上所有答案都不适合我使用CHROME

我的应用程序正确启动从http://example.com/someresource/链接从应用程序,如hangouts, gmail等,但不是从chrome浏览器。

为了解决这个问题,让它从CHROME正确启动,你必须像这样设置意图过滤器

<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data
        android:host="example.com"
        android:pathPrefix="/someresource/"
        android:scheme="http" />
    <data
        android:host="www.example.com"
        android:pathPrefix="/someresource/"
        android:scheme="http" />
</intent-filter>

注意pathPrefix元素

您的应用程序现在将出现在活动选择器内,每当用户请求http://example.com/someresource/模式从chrome浏览器点击谷歌搜索结果或任何其他网站的链接

嘿,我有办法了。我没有将类别设置为“默认”。此外,我使用的主要活动的意图数据。现在我正在使用一个不同的活动的意图数据。谢谢你的帮助。:)

例如,你有下面的事情:

打开应用程序的链接:http://example.com

应用程序的包名:com.example.mypackage

接下来你需要做的是:

Add an intent filter to your Activity (Can be any activity you want. For more info check the documentation). <activity android:name=".MainActivity"> <intent-filter android:label="@string/filter_title_view_app_from_web"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- Accepts URIs that begin with "http://example.com" --> <data android:host="example.com" android:scheme="http" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Create a HTML file to test the link or use this methods. Open your Activity directly (just open your Activity, without a choosing dialog). Open this link with browser or your programm (by choosing dialog). Use Mobile Chrome to test That's it.

没有必要在市场上发布应用程序来测试深度链接=)

此外,要获得更多信息,请查看文档和有用的演示文稿。