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


当前回答

请在这里看到我的评论:在Android浏览器中创建一个链接启动我的应用程序?

我们强烈反对人们使用他们自己的方案,除非他们正在定义一个新的全球互联网方案。

其他回答

看这里@JRuns的答案。这个想法是用您的自定义方案创建html,并将其上传到某个地方。然后,如果你点击你的html文件上的自定义链接,你将被重定向到你的应用程序。但是不要忘记设置全名name = "MyApp.Mobile.Droid. "MainActivity”属性到你的目标活动。

截至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浏览器点击谷歌搜索结果或任何其他网站的链接

在我的例子中,我必须为<intent-filter>设置两个类别,然后它就工作了:

<intent-filter>
<data android:scheme="my.special.scheme" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>

截至2019年6月15日

我所做的是包括所有四种打开url的可能性。

也就是说,有HTTP / HTTPS, 2有WWW前缀,2没有WWW

通过使用这个,我的应用程序现在自动启动,而不需要我选择浏览器和其他选项。

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="https" android:host="example.in" />
    <data android:scheme="https" android:host="www.example.in" />
    <data android:scheme="http" android:host="example.in" />
    <data android:scheme="http" android:host="www.example.in" />

</intent-filter>

example.php:

<?php
if(!isset($_GET['app_link'])){  ?>   
    <iframe src="example.php?app_link=YourApp://blabla" style="display:none;" scrolling="no" frameborder="0"></iframe>
    <iframe src="example.php?full_link=http://play.google.com/xyz" style="display:none;" scrolling="no" frameborder="0"></iframe>
    <?php 
}
else { ?>
    <script type="text/javascript">
    self.window.location        = '<?php echo $_GET['app_link'];?>';
    window.parent.location.href = '<?php echo $_GET['full_link'];?>';
    </script>
<?php 
}