import android.support.v4.app.ShareCompat;
Uri pdfUri = Uri.parse("file://sdcard/sdcard0/test.pdf");
Intent shareIntent = ShareCompat.IntentBuilder.from(this)
.setText("Share PDF doc")
.setType("application/pdf")
.setStream(pdfUri )
.getIntent()
.setPackage("com.google.android.apps.docs");
startActivity(shareIntent);
If you need to upload data from a Service instead of an Activity all you have to do is creating a "dummy activity", insert the above ShareCompat code in the onCreate() method and put finish() after the startActivity(shareIntent) command.
Other Intents can be targeted with similar code, changing the package name, e.g.
Other Intents can be targeted with similar code, changing the package name, e.g.
- com.dropbox.android = Dropbox
- com.android.bluetooth = Bluetooth
- com.android.email = Email
- com.google.android.gm = Gmail
- com.microsoft.skydrive = Skydrive
- com.google.android.apps.docs = Googledrive
for the dropbox is not working for now.
ReplyDeletethis code works for android phone or only glass?
i need send a image direct to dropbox but i dont find any example on the internet, if you know how send a image via intent to dropbox send me pls. many thx
That was a workaround I found two years ago specifically crafted to work on Google Glass. Personally I have not tested it outside the gdk (glass development kit) but (at that time) it should have worked on the Android regular sdk too. Probably some of the functions in the API Are changed so you need to update this fragment of code accordingly.
ReplyDelete