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

后端 未结 1 1003
野性不改
野性不改 2020-12-03 02:05

I tried to upload a file from my android application by manually launching Google drive (installed on the device). I tried this to send using Intent.createChooser

相关标签:
1条回答
  • 2020-12-03 02:54

    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 = {"test@gmail.com"};              
    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);
    
    0 讨论(0)
提交回复
热议问题