我决定研究将静态快捷方式添加到应用程序中,使用这个页面作为参考:
https://developer.android.com/preview/shortcuts.html
目前我的快捷方式XML文件如下:
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="id"
android:enabled="true"
android:icon="@drawable/icon"
android:shortcutShortLabel="@string/short_label"
android:shortcutLongLabel="@string/long_label"
android:shortcutDisabledMessage="@string/disabled_message">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.example"
android:targetClass="com.example.Activity" />
<categories android:name="android.shortcut.category" />
</shortcut>
</shortcuts>
问题出在targetClass
变量上,因为我找不到一种方法来启动一个Fragment
而不是Activity
。 我想从快捷方式启动的大多数主要页面都是在Activity
中显示的Fragments
。 我该如何让intent
直接启动一个Fragment
呢?
Activity
启动那个Fragment
。目前我甚至找不到启动一个Fragment
子级的方法。 - edwoollard