lim*_*nal 3 android android-architecture-components android-architecture-navigation
我正在尝试使用新的导航组件API v1.0.0-alpha05实现深层链接功能,但遇到了问题。
使用Android Studio 3.3 Canary 7
我的navigation_graph.xml的一部分
<fragment
android:id="@+id/noteDetailFragment"
android:name="com.myapp.notes.notedetail.NoteDetailFragment"
android:label="@string/label_note_detail"
tools:layout="@layout/note_detail_fragment">
<argument
android:name="noteId"
android:defaultValue="0"
app:argType="integer" />
<action
android:id="@+id/action_noteDetail_to_editNote"
app:destination="@id/editNoteFragment" />
<deepLink
android:id="@+id/noteDetailDeepLink"
app:uri="notesapp://notes/{noteId}" />
</fragment>
Run Code Online (Sandbox Code Playgroud)
AndroidManifest.xml包含:
<activity android:name=".presentation.MainActivity">
<nav-graph android:value="@navigation/navigation_graph" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
我正在测试我的深层链接 adb shell am start -a android.intent.action.VIEW -d "notesapp://notes/2" com.myapp.notes
的noteId是不存在于任一NoteDetailFragmentArgs.fromBundle(arguments).noteId或arguments?.getInt("noteId", 0)(的默认值0在两种情况下被返回)
打印出捆绑包表明它在那里:
[{android-support-nav:controller:deepLinkIntent=Intent { act=android.intent.action.VIEW dat=notesapp://notes/2 flg=0x1000c000 pkg=com.mynotes.notes cmp=com.mynotes.notes.presentation.MainActivity }, noteId=2}]
如果Deeplink uri是 http://www.mynotes.com/notes/2
noteId深层链接时如何访问?谢谢!
| 归档时间: |
|
| 查看次数: |
892 次 |
| 最近记录: |