packing my app and share to other + android

爷,独闯天下 提交于 2019-12-01 08:34:28
hamedh.1990

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());
        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!