Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: google docs send intent?

Tags:

android

My application includes a send feature which presents a list of installed programs to use to send a document. It does this with:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("application/zip");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ docPath));
startActivity(Intent.createChooser(sendIntent, "Email"));

Apps like Gmail and Dropbox appear in the list, but Google Docs does not. In competitor's apps that use the same document type, Google Docs does appear as an intent. Do I have to use some other method or intent type to get Google Docs to show?

like image 692
ab11 Avatar asked Feb 21 '23 16:02

ab11


1 Answers

You can research it yourself, run DDMS or LogCat view in Eclipse, and watch debug log written when your or other app starts activity for ACTION_SEND intent.

You'll see:

ActivityManager: START {act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras)}

Then follow also log when you actually choose app for sending. You'll see something like this:

ActivityManager: START {act=android.intent.action.SEND typ=application/zip flg=0x13000000 cmp=com.android.bluetooth/.opp.BluetoothOppLauncherActivity (has extras)}

Or you may also see this:

ActivityManager: START {act=android.intent.action.SEND typ=*/* flg=0x13000000 cmp=com.google.android.apps.docs/.shareitem.UploadSharedItemActivity (has extras)}

You see difference here. One app sets actual mime type = application/zip, other app sets mime type */*. This means that Docs app isn't designed to send zip files.

Exploring further, use nice app AppXPlore, open Docs, re-create manifest of Docs app, and look at block with UploadSharedItemActivity (the one which matched */* type), on its intent-filter block:

<activity label="Docs" name=".shareitem.UploadSharedItemActivity">
<intent-filter>
   <action name="android.intent.action.SEND" />
   <action name="android.intent.action.SEND_MULTIPLE" />
   <category name="android.intent.category.DEFAULT" />
   <data mimeType="video/*" />
   <data mimeType="image/*" />
   <data mimeType="text/*" />
   <data mimeType="application/x-vnd.oasis.opendocument.spreadsheet" />
   <data mimeType="application/vnd.ms-powerpoint" />
   <data mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document" />
   <data mimeType="application/msword" />
   <data mimeType="application/pdf" />
   <data mimeType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
   <data mimeType="application/pdf" />
   <data mimeType="application/rtf" />
   <data mimeType="application/vnd.ms-excel" />
   <data mimeType="application/vnd.oasis.opendocument.text" />
   <data mimeType="application/vnd.sun.xml.writer" />
</intent-filter>

This proves that Docs app is designed to send predefined file types, Zip is not among them.

You app can respect this decision of Docs app, or it can send with */* mime type, but in such case user may be confused why there're unexpected apps that don't handle Zip files in the list. I'd rely on 1st option, and using actual mime type.

like image 78
Pointer Null Avatar answered Feb 24 '23 06:02

Pointer Null