启动活动时出错

use*_*595 3 deep-linking

我在清单文件中为我的一个活动定义了一个intent过滤器.当我尝试从adb shell启动此活动时,使用以下命令:

$ adb shell am start

    -W -a android.intent.action.VIEW

    -d "example://gizmos" com.example.android
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

开始:Intent {act = android.intent.action.VIEW dat = http://www.example.com/gizmos pkg = com.example.android}

错误:活动未启动,无法解析Intent {act = android.intent.action.VIEW dat = http://www.example.com/gizmos flg = 0x10000000 pkg = com.example.android}

请帮忙.

这是清单条目:

  <activity

        android:name="com.example.android.activity.ExampleActivity"

        android:configChanges="orientation|keyboardHidden|screenSize"

        android:screenOrientation="portrait" >

        <intent-filter android:label="Search" >

            <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 "example://gizmos” -->

            <data

                android:host="gizmos"

                android:scheme="example" />

            <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->

            <data

                android:host="www.example.com"

                android:pathPrefix="gizmos"

                android:scheme="http" />

        </intent-filter>

    </activity>
Run Code Online (Sandbox Code Playgroud)

小智 6

编辑AndroidManifest.xml如下:

<intent-filter>
<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 "example://gizmos” -->
<data
   android:host="gizmos"
   android:scheme="example" />
</intent-filter>

<intent-filter>
<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://www.example.com/gizmos” -->
<data 
    android:host="www.example.com"
    android:pathPrefix="gizmos"
    android:scheme="http" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)