这是我使用 chiuki 的以下建议提出的解决方案:
我在我的一个资源文件中添加了一个布尔值,指示该应用程序是在 Amazon AppStore 还是在 Android Market 中发布。是的,每当你发布你的应用程序时,你都必须更改它,但想想它有点像在发布时记得将 debuggable 设置为“false”。把它放在检查清单上。它是这样的:
在资源文件中:
<bool name="app_is_in_amazon_app_store">true< /bool>
在代码中:
public class SomeUtil
{
private static Boolean isInAmazonAppStore;
public static boolean isInAmazonAppStore(Activity activity)
{
if (isInAmazonAppStore == null)
{
isInAmazonAppStore = activity.getResources().getBoolean(R.bool.app_is_in_amazon_app_store) ;
}
return isInAmazonAppStore;
}
public static void startOtherMarketAppsActivity(Activity activity)
{
try
{
Intent otherApps = null;
if (isInAmazonAppStore(activity))
{
otherApps = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.amazon.com/gp/mas/dl/android?p=" + getPackageNameInAmazonAppStore(activity) + "&showAll=1"));
}
else
{
otherApps = new Intent(Intent.ACTION_VIEW,Uri.parse("market://search?q=pub:\"" + getAndroidDeveloperName(activity) + "\""));
}
activity.startActivity(otherApps);
}
catch(Exception ex){ /* error handling */}
}