android - 有没有办法从偏好中将额外内容添加到 Intent 中?

标签 android android-intent intentfilter extras

您好,我正在从首选项屏幕启动 Activity 。 Activity 在三个偏好之间共享。 我想知道我是否可以在 xml 中为此 Activity 设置额外内容

<Preference
    android:key="action_1"
    android:title="@string/action_1_title"
>
    <intent
        android:action="com.package.SHAREDACTION"
    >

    </intent>
</Preference>

我想知道我是否可以做类似的事情

<extras>
     <item
      android:name=""
      android:value=""/>
</extras>

我真正需要做的就是传递一个整数。我可以使用不同的操作和检查操作而不是附加操作。

最佳答案

我得到了答案,你可以这样使用:

<Preference
    android:key="xxx"
    android:title="xxx"
    android:summary="xxx">
   <intent android:action="xxx" >
         <extra android:name="xxx" android:value="xxx" />
    </intent>        

</Preference>

关于android - 有没有办法从偏好中将额外内容添加到 Intent 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2082640/

相关文章:

android - 如何将 Activity 从下拉菜单中的通知放在前面?

android - 如何在 Android Activity 之间共享 socket.io 连接?

android - 如何在 Android 上分享照片时过滤应用程序

Android - 开始新 Activity 时保存 Activity 状态

android - 如何获取域链接以在 Android 上打开我的应用程序?

android - intent.getCategories() 为空,尽管它已设置

android - 如何处理耳机 Hook 的双击?

android - 如何在 Android 上管理 startActivityForResult

java - Android 日历事件的 BroadcastReceiver (2018)

android - Twitter4j Stream 获取自己的个人资料推文