谁能指导我如何从android浏览器启动我的android应用程序?
当前回答
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
}
其他回答
截至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>
嘿,我有办法了。我没有将类别设置为“默认”。此外,我使用的主要活动的意图数据。现在我正在使用一个不同的活动的意图数据。谢谢你的帮助。:)
例如,你有下面的事情:
打开应用程序的链接: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.
没有必要在市场上发布应用程序来测试深度链接=)
此外,要获得更多信息,请查看文档和有用的演示文稿。
Felix处理深度链接的方法是处理深度链接的典型方法。我还建议您查看这个库来处理深层链接的路由和解析:
https://github.com/airbnb/DeepLinkDispatch
您可以使用注释为特定的深链接URI注册Activity,它将为您提取参数,而不必执行获取路径段、匹配它等通常的繁琐操作。你可以像这样简单地注释和活动:
@DeepLink("somePath/{someParameter1}/{someParameter2}")
public class MainActivity extends Activity {
...
}
还应该有<category android:name="android.intent.category. browsable "/>添加到intent过滤器中,以便从链接中正确识别活动。
推荐文章
- 如何设置RecyclerView应用程序:layoutManager=""从XML?
- 在没有开发服务器的情况下在设备上构建和安装unsigned apk ?
- 操作栏和新引入的工具栏有什么不同?
- 调整浮动动作按钮图标大小(fab)
- Android Studio无法找到有效的Jvm(与MAC OS相关)
- android:在触摸移动时移动视图
- 如何以编程方式将ID分配给视图?
- 如何解决INSTALL_FAILED_DEXOPT错误?
- 有没有办法自动安装Android SDK ?
- 如何检查一个视图在Android中是否可见?
- Android是否保留。apk文件?如果有,在哪里?
- 在Android 5棒棒糖中,通知栏图标变成白色
- 从URI获取真实路径,Android奇巧新的存储访问框架
- 如何检查JSON键是否存在?
- ImageView -有高度匹配宽度?