共享應用我已經創建了我的應用程序分享按鈕,它會通過意向分享我的整個應用程序。它是這樣工作的:重命名文件名通過意向
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());
}
現在,這個會送我的應用程序與我的包名。我需要分享喜歡這張例如前,它與我的應用程序名稱重命名:
PackageManager packageManager= getApplicationContext().getPackageManager();
String appName = (String) packageManager.getApplicationLabel(
packageManager.getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA));
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
String version = pInfo.versionName;
String shareName = appName+"_"+"v"+version;
有沒有辦法重命名我的包名這種「共享名」字符串?