I'm new to android and I'd like to let users to share the app's apk.
Here is the function:
protected void shareApp(View view){
Intent i = new Intent(Intent.ACTION_SEND);
i.shareIntent.setType("*/*");
Uri path = Uri.parse("/data/apps/"+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(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
}
The emails are sent but without the .apk
file.
On the other hand If I remove i.shareIntent.setType("*/*");
I get this error:
Unable to find application to perform this action.
I know that this question has asked before, but I could not find my answer there.
What is wrong with the function and how can I fix it?