所以我正在处理冲突。我正试图从我的应用程序中启动谷歌游戏商店,我实现了该功能。但是,我只能对URI中的包值进行硬编码才能使其正常工作。我需要一种方法,我可以使用getPackageName()并从google play store返回正确的方法。
在URI中使用的Google Play商店包名称:org.horaapps.leafpic
包名称getPackageName()返回:org.horaapps.leafpic.debug
以下是启动Google Play的代码:
//Launches to the app in google play, if the package name ever does change you can do this
//by changing the org section of the URI below. -beastlyCoder
Uri uri = Uri.parse("market://details?id=org.horaapps.leafpic"); //dont want hardcoded value
Log.d("tag", getApplicationContext().getPackageName());
Intent myAppLinkToMarket = new Intent(Intent.ACTION_VIEW, uri);
try
{
startActivity(myAppLinkToMarket);
} catch (ActivityNotFoundException e)
{
Toast.makeText(this, " unable to find market app", Toast.LENGTH_SHORT);
}
如何在最后删除调试,以便两个软件包可以对应,(注意:这是一个开源项目,所以我不希望对代码进行任何重大更改,如更改软件包结构和所有那个。)
答案 0 :(得分:1)
Set your build variant to release and add this in your app level build.gradle:
buildTypes {
release {
applicationId "org.horaapps.leafpic"
}
debug {
applicationIdSuffix ""
}
}