Android Launch a Google Drive application from another application not uploaded file

I got the solution for executing following code after research:

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

Similarly we can use for other share intent and the corresponding package name of few intents are as below:

  • 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 gmail sharing we need to use following type of code:

Uri zipUri = Uri.parse("file://sdcard/sdcard0/test.zip");  
String[] emailArr = {"[email protected]"};              
Intent shareIntent = ShareCompat.IntentBuilder.from(this)
                                  .setText("Share ZIP doc")
                                  .setType("application/zip")
                                  .setEmailTo(emailArr)
                                  .setStream(zipUri)
                                  .setSubject("Share zip doc")
                                  .setText("Sent with email app.")
                                  .getIntent()
                           .setPackage("com.google.android.gm");
startActivity(shareIntent);

Leave a Comment