gpt4 book ai didi

android-intent - 将我的应用程序添加到 "Complete Action Using"列表中,用于 Gmail 中的附件

转载 作者:行者123 更新时间:2023-12-04 23:26:29 25 4
gpt4 key购买 nike

我希望我的应用出现在 gmail 的列表中。当我单击 Gmail 应用程序中的“预览”按钮时,会出现此列表。

我想知道需要在意图过滤器中添加哪些条目?

我在这里先向您的帮助表示感谢。

最佳答案

看看意图过滤器:
http://developer.android.com/guide/components/intents-filters.html

具体来说,我认为您会发现 Note Pad Example 很有帮助:
http://developer.android.com/guide/components/intents-filters.html#npex

就个人而言,几个小时前我遇到了同样的问题。我需要用我的应用程序打开文本文件。为此,我必须将其添加到我的 list 中:

<activity
android:name=".(ActivityName)"
android:label="@string/app_name"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.apps.drive.DRIVE_OPEN" />
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.INSERT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>

仅此而已,我就能够让我的应用程序出现在可用应用程序列表中,以从 Astro 打开文本文件,并允许它启动。

要使其实际处理打开文件,您需要在事件中的 onCreate 中添加如下内容:
Intent intent = getIntent();
Action action = intent.getAction();
if (action.equals("com.google.android.apps.drive.DRIVE_OPEN")) {
// Handle the intent from google drive...
} else if (action.equals("android.intent.action.VIEW")) {
// Handle the intent to view the file...
} else // And so on...

关于android-intent - 将我的应用程序添加到 "Complete Action Using"列表中,用于 Gmail 中的附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12176983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com