我正在尝试通过adb测试android深度链接网址以启动我的应用 [英] I am trying to test android deep link urls through adb to launch my app

查看:825
本文介绍了我正在尝试通过adb测试android深度链接网址以启动我的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在adb中键入命令时:

When I type the command in adb:

./adb shell am start -W -a android.intent.action.VIEW -d "example:gizmos" com.myapp

我收到此错误:

Starting: Intent { act=android.intent.action.VIEW dat=example://gizmos pkg=com.myapp }
Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=example://gizmos flg=0x10000000 pkg=com.myapp }

但是当我在adb中键入命令时:

But when I type the command in adb:

./adb shell am start -W -a android.intent.action.VIEW -d "example:gizmos" com.myapp.activity.DeepLinkActivity

一切正常,我收到消息,并且可以在电话上看到活动启动。

Everything works fine and I get the message and I can see the activity launch on the phone:

Starting: Intent { act=android.intent.action.VIEW dat=example://gizmos cmp=com.myapp.activity.DeepLinkActivity }
Status: timeout
Activity: com.myapp.activity.DrawerActivity
Complete

我的问题是为什么我需要获得活动的完整路径而不仅仅是包裹名字?因为当外部应用或浏览器尝试进行深度链接时,它们将不会调用我的应用中的活动。

My question is why do I need to get full path of my activity and not just package name? Because when the external apps or browser will try to deep link they will not invoke the activity in my app.

这是我的AndroidManifest.xml

This is my AndroidManifest.xml

<activity
        android:name=".activity.DeepLinkActivity">
        <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:scheme="example"
                  android:host="gizmos" />

        </intent-filter>
</activity>


推荐答案

您无需指定完整路径活动,但是如果您想测试您对URI 中的反应是否正确,只需指定应用程序包即可:

You don't need to specify full path to your activity, but if you want to test whether you react properly to URI in your app just specify app package:

adb shell am start -a android.intent.action.VIEW -d "example://gizmos" com.myapp

您提供的命令中也有错误-应该有 example:// gizmos 而不是 example:gizmos

Also there is bug in command you provided - there should be example://gizmos not example:gizmos

这篇关于我正在尝试通过adb测试android深度链接网址以启动我的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆