SKK*_*SKK 5 android-shortcut android-shortcutmanager
在使用 Shortcut.xml 实现静态快捷方式时,我想根据我的意图传递一些捆绑包附加内容。
启动应用程序后,需要传递额外的内容来决定目标类中的一些功能。
是否可以访问额外内容?如何以及在哪里访问它?
任何线索将不胜感激
小智 6
我不确定是否还有其他方法,但我使用这个:
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="target.package"
android:targetClass="activity.with.package">
<extra android:name="extraID" android:value="extravalue" />
</intent>
Run Code Online (Sandbox Code Playgroud)
然后您就可以像往常一样访问附加功能。
那么为什么不创建动态快捷方式呢?
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
Intent thirdIntent = new Intent(this,ThirdActivity.class);
thirdIntent.setAction(Intent.ACTION_VIEW);
ShortcutInfo thirdScreenShortcut = new ShortcutInfo.Builder(this, "shortcut_third")
.setShortLabel("Third Activity")
.setLongLabel("This is long description for Third Activity")
.setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher))
.setIntent(thirdIntent)
.build();
shortcutManager.setDynamicShortcuts(Collections.singletonList(thirdScreenShortcut));
Run Code Online (Sandbox Code Playgroud)
您可以传递您想要发送的任何内容Intent并将其访问到接收者活动。
| 归档时间: |
|
| 查看次数: |
2207 次 |
| 最近记录: |