APK名変更でアプリを共有するために、あなたは以下の方法を使用してSDカードにAPKファイルをコピーすることができ、APK今
public static File copyFile(ApplicationInfo appInfo, File folderName, String apkName) {
File initialFile = new File(appInfo.getSourceDir());
File finalFile = new File(folderName, apkName);
try {
FileInputStream inStream = new FileInputStream(initialFile);
FileOutputStream outStream = new FileOutputStream(finalFile);
FileChannel inChannel = inStream.getChannel();
FileChannel outChannel = outStream.getChannel();
inChannel.transferTo(0, inChannel.size(), outChannel);
inStream.close();
outStream.close();
} catch (IOException e) {
e.printStackTrace();
}
return finalFile;
}
作成のためApplicationItem、期待されるフォルダと新しい予想される名前を渡しますあなたがコピーしたファイルを使用する意図。最後に
public static Intent getShareIntent(File file) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
intent.setType("application/vnd.android.package-archive");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return intent;
}
アプリを共有することができ、
ApplicationInfo app = getApplicationContext().getApplicationInfo();
File newFile = copyFile(app, Environment.getExternalStorageDirectory(), "[Expected name].apk");
Intent shareIntent = getShareIntent(newFile);
startActivity(Intent.createChooser(shareIntent, "Sharing [Appname] Apk"));
なぜあなたは自分のプレイストアのリンクを共有しませんか?単に好奇心を求める。 –
大学のプロジェクトで、店舗で公開されないため – Mahdi