0

I am trying to send apk through application which have capability to send applications, I tested all the answers but I get this toast message. the file format is not supported,,,,

this is my the code that I have test

public  void shareApp() {
        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("application/vnd.android.package-archive");
        Uri path = Uri.parse("/data/apps/"+getActivity().getApplicationContext().getPackageName()+".apk");
        i.putExtra(Intent.EXTRA_SUBJECT, "Here is the fancy app");
        i.putExtra(Intent.EXTRA_TEXT, "Don't miss it!");
        i.putExtra(Intent.EXTRA_STREAM, path);
        try {
            startActivity(Intent.createChooser(i, "Share via"));
        } catch (android.content.ActivityNotFoundException ex) {
           Toast.makeText(getContext(), "There are no email clients installed.", Toast.LENGTH_SHORT).show();

    }}
NawalSalameh
  • 109
  • 1
  • 13
  • 1
    That's not a valid `Uri`. A `Uri` has a scheme, for starters. – CommonsWare Oct 11 '16 at 14:57
  • A scheme such as `file:` which is forbidden starting Android 7 so good luck using this method. Plus the file often has a postfix such as `-2`. Find another way. – Eugen Pechanec Oct 11 '16 at 15:04
  • thank you ,i have try many codes. and all gives me the same message. – NawalSalameh Oct 11 '16 at 15:09
  • Possible duplicate of [How to Share Entire Android App with Share Intent](http://stackoverflow.com/questions/13941093/how-to-share-entire-android-app-with-share-intent) – zombie Oct 11 '16 at 16:16

0 Answers0