Android - Java Apache Config Windows Batch Linux Bash CSS Gradle HTML ini File iOS - Swift Java JavaScript JSON Format Kotlin LESS Markdown MySQL PHP Plain Text Properties File Rust Go Lang SCSS Swift XML
public static boolean shareApp(Context context, String packageName, String title) {
try {
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
PackageManager pm = context.getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo(packageName, 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));
context.startActivity(Intent.createChooser(share, title));
return true;
} catch (Exception e) {
return false;
}
}