2

I am developing an app which shares APK file. For that I have used Intent Chooser to display related/supported applications. In that if I select Gmail app now able to see attached file while composing & sent, but not received any attachment. But when I transfer via Bluetooth it is working fine. I don't know what is wrong with my code

My implementation like, sending Byte content from URI. Please help me out from this.

private void sendApk(String apkSourcePath2) {

     Intent sharingIntent = new Intent(Intent.ACTION_SEND);
    sharingIntent.setType("application/*");

    String shareBody = "Please find the attached APK file...";
    String subject = "From EasyShare";
    sharingIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(apkSourcePath2)));
    sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
    startActivity(Intent.createChooser(sharingIntent, "Send/Share via.."));

}

Here apkSourcepath2 is pointing to Packageinfo.sourceDir

And also my question is, does Gmail cannot access file from data/app folder?

Any suggestions to implement this module????

njzk2
  • 38,969
  • 7
  • 69
  • 107
saravana
  • 544
  • 1
  • 7
  • 26

1 Answers1

3

All depends on the value of apkSourcePath2.

If it is inside your app sandbox, it can't be accessed by any other app. You could use a content provider for this.

Snicolas
  • 37,840
  • 15
  • 114
  • 173
  • apkSourcePath2 will be like this data/app/.apk – saravana Nov 15 '13 at 15:45
  • that is your sandbox. Use a ContentProvider to share access to other apps : http://stackoverflow.com/q/12170386/693752 or put the apk somewhere else, like on SDcard, where all apps can read and write. – Snicolas Nov 15 '13 at 15:56
  • I thought my app will read file from the mentioned path (data/app/.apk and also should I copy the apk file to some other location? – saravana Nov 15 '13 at 16:05