我有一个应用程序,我想重新标记它。这是我分享 Intent 的代码:
String shareBody = "https://play.google.com/store/apps/details?id=" + mContext.getPackageName();
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mContext.getResources().getString(R.string.enjoy_this_app));
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
mContext.startActivity(Intent.createChooser(sharingIntent, "Please Choose"));
我已经更改了项目中每个地方的包名称,但 mContext.getPackageName() 仍然返回旧名称。 (包名称在 list 、gradle 文件、项目 Pane 中更改...)
我检查了这里的很多帖子,我做了所有推荐的事情。没有任何效果。 我检查的帖子:
Android Studio Rename Package How to change package name of an Android Application How to change package name in android studio? Android Studio Rename Package
知道出了什么问题吗?
提前致谢。
最佳答案
好吧,即使我更改了包名称,我也遇到了类似的问题,但它仍然给我旧包...
修复它转到 build.gradle 文件并手动将 applicationId 替换为您的新包名称。 这不受重命名包的影响
关于android - 更改 mContext.getPackageName() 返回的包名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40747315/