は、私は両方のゲームの存在を検出することによって、問題を「解決」する方法ですが、その後、デモ版をアンインストールするよう促す、誰もが将来に興味がある必要があります。
public class UpdateManager {
public static void checkForBothVersions(final Activity activity) {
PackageManager packageManager = activity.getPackageManager();
//# We want to intentionally cause an Exception. This will let us know
//# whether there is only one version installed.
try {
packageManager.getPackageInfo("package.full", 0);
packageManager.getPackageInfo("package.demo", 0);
//# If we get here, then both are installed. Let's display our warning.
Builder builder = new AlertDialog.Builder(activity);
builder.setTitle("Warning!");
builder.setMessage("" +
"We've detected that you have both the FULL and DEMO versions of Application installed.\n" +
"This can cause undesired results. We suggest uninstalling the DEMO version of Application." +
"")
.setCancelable(false)
.setPositiveButton("Uninstall DEMO", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Uri uri = Uri.parse("package:package.demo");
//# Start the delete intent for the demo
activity.startActivity(new Intent(Intent.ACTION_DELETE, uri));
//# We don't wanna call finish here. We want the delete Intent to open
//# and once the user closes that Intent, it should go back to the
//# calling RB Activity and call onResume where the check cycle will
//# restart.
}
})
.setNegativeButton("Continue", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
activity.startActivity(new Intent("package.lib.SplashActivity"));
activity.finish();
}
});
AlertDialog alert = builder.create();
alert.show();
}catch(Exception e) {
Log.i("UpdateManager", "Only one version of Application installed.");
activity.startActivity(new Intent("package.lib.SplashActivity"));
activity.finish();
}
}
}
私はちょうどからこのメソッドを呼び出しますデモアプリケーションとフルアプリケーションのonResumeメソッド。
両方がインストールされているのは避けられないと思います。両方のapkが存在するかどうかをapkのチェックで確認することができます。両方とも存在する場合は、デモ版をアンインストールするよう促します。あなたが正しいインテントを立ち上げると、ボタンを押すだけで、設定や何も掘り下げなくてもいいので、アンストール[あなたのデモアプリ]ページにまっすぐに進むことができます。 – FoamyGuy
ええ、それはちょっと私が考えていたものです。私はあなたが示唆したようにデモアンインストールポップアップを作成します。ご協力いただきありがとうございます;あなたがあなたの答えを投稿するならば、私はこれを解決したとマークします。 –
アクティビティを開くためにどのようなインテントパターンを使用しますか? AndroidManifest.xml(アクティビティが定義されている仕組み)でコードスニペット(アクティビティがどのように開かれるか)を投稿できますか? – yorkw