How to test custom URL scheme in android

醉酒当歌 提交于 2019-11-30 08:24:09

That is easy via adb. Check this command:

adb shell am start -a android.intent.action.VIEW -d "appname://appnamehost" your.package.name

However you should use your package name as schema. So you can be absolutely sure that there is no conflict (or in detail a intent chooser).

If you have multiple devices you need to execute adb devices. This will result a output like this:

List of devices attached
1645e1d0b86b    device
S9WM00904386    device

Then you can use that id from above to address a concrete device with the -s parameter. This will result a command line like this:

adb -s S9WM00904386 shell [...]

In case of a browser link this is also easy. You just need to add this line of html:

<a href="appname://appnamehost">Click me</a>

If you want a fallback in your url you could try the intent url:

<a href="intent://apphostname#Intent;scheme=appname;package=your.package.name;S.browser_fallback_url=http%3A%2F%2Fwww.example.com;end">with alternative</a>

This will open your app even if you schema is not unique, and if you app is not installed it will open example.com.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!