Add my app to the list of “Complete Action Using” for attachments in gmail

百般思念 提交于 2019-12-04 13:21:52

问题


I would like my app to appear in the list within gmail. This list comes up when I click the Preview button within the Gmail app.

I would like to know what entries need to be added in the intent filter?

Thanks for the help in advance.


回答1:


Have a look at Intent Filters: http://developer.android.com/guide/components/intents-filters.html

Specifically, I think you'll find the Note Pad Example helpful: http://developer.android.com/guide/components/intents-filters.html#npex

Personally, I had this same exact issue a few hours ago. I needed to open text files with my app. To do so, I had to add this to my manifest:

<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>

With just this, I was able to make my app appear in the list of available applications to open text files from Astro, and allow it to be launched.

To make it actually handle opening the files, you need to add something like this to your onCreate in the activity:

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...


来源:https://stackoverflow.com/questions/12176983/add-my-app-to-the-list-of-complete-action-using-for-attachments-in-gmail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!