I\'m creating an application for Android and I need a button to send my application to another phone.
I tried to put an apk and send to other but I can\'t do it. I\'
resolved ...
try {
PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo(getPackageName(), 0);
File srcFile = new File(ai.publicSourceDir);
Intent share = new Intent();
share.setAction(Intent.ACTION_SEND);
share.setType("application/vnd.android.package-archive");
share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(srcFile));
startActivity(Intent.createChooser(share, "PersianCoders"));
} catch (Exception e) {
Log.e("ShareApp", e.getMessage());
}
i find the code for changing base.apk to special file name ...
try {
PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo(getPackageName(), 0);
File srcFile = new File(ai.publicSourceDir);
File outputFile = new File(Environment.getExternalStorageDirectory(),
"hamed-heydari_Com" + ".apk");
Tools.copy(srcFile, outputFile);
Intent share = new Intent();
share.setAction(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_TEXT, Tools.getStringByName("installApp") + " " + Tools.getStringByName("app_name"));
share.setType("application/vnd.android.package-archive");
share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(outputFile));
startActivity(Intent.createChooser(share, "Share App ..."));
} catch (Exception e) {
Log.e("ShareApp", e.getMessage());
}