Android: Share apk file from application 2017 | Share intent

Android Send installed apps apk file

All we want marketing in android sharing apk option is one of the best strategy to spread your application one to another. If this feature is inbuilt in your application thats better. Here in this example we give you two ways to share your android application with other. Share apk file is very important part of share intent learn thoroughly. In this first example you will get code to share raw apk file using intent. We want to provide some new code which will be support in android newer version Android lollipop, Marshmallow, Nougat and latest version android Oreo. If you get any deprecation alert please let us know through comment. Your reply is valuable for us. Stop use of old deprecated code. Get more information about sharing intent from Android official page. More here share audio file from android raw folder also share audio file from internal storage.

share apk file

1. How to share apk file in android programmatically

Button apk = (Button) findViewById(R.id.shareApk);
apk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

ApplicationInfo app = getApplicationContext().getApplicationInfo();
String filePath = app.sourceDir;
Intent intent = new Intent(Intent.ACTION_SEND);

// but Bluetooth does not accept this. Let’s use “*/*” instead.
intent.setType(“application/vnd.android.package-archive”);

// Append file and send Intent
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filePath)));
startActivity(Intent.createChooser(intent, “Share app using”));
}
});

2. How to share app link in android programmatically

Button shareAppLink = (Button) findViewById(R.id.shareApp);
shareAppLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, “Install my app: https://play.google.com/store/apps/details?id=com.google.android.apps.plus”);
sendIntent.setType(“text/plain”);
//startActivity(Intent.createChooser(sendIntent, “Share via”));
//startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
startActivity(sendIntent);
}
});

Visit Blog NextGenEarn and know how to earn money from home easily from online without huge investment. Here you learned about how to share apk file. How to share images in android application. How to share with social network app directly from your application like Twitter, Facebook and whatsapp.

Add a Comment

Your email address will not be published. Required fields are marked *