2012-04-27 9 views
0

私のアプリケーションのコードベースを含むライブラリプロジェクトがあります。私はデモとフルリリースを持っています。このライブラリにはすべてのアクティビティが含まれています。ほとんどのプレイヤーはデモで始まり、好きな人はフルバージョンを手に入れます。しかし、彼らはすぐにデモをすぐにアンインストールせずに、同時にデバイス上でデモを実行することはしません。これはポップアップを引き起こし、どのアプリケーション(デモまたはフル)がアクティビティを通してプレーヤーのムービーとして各アクティビティを開くかを尋ねます。複数のAPKが同じコードベースを使用しているため、ユーザーに不便を招く

これを防ぐ方法はありますか、または両方のAPKを同時にデバイスに搭載することはやむを得ない副作用ですか?

+0

両方がインストールされているのは避けられないと思います。両方のapkが存在するかどうかをapkのチェックで確認することができます。両方とも存在する場合は、デモ版をアンインストールするよう促します。あなたが正しいインテントを立ち上げると、ボタンを押すだけで、設定や何も掘り下げなくてもいいので、アンストール[あなたのデモアプリ]ページにまっすぐに進むことができます。 – FoamyGuy

+0

ええ、それはちょっと私が考えていたものです。私はあなたが示唆したようにデモアンインストールポップアップを作成します。ご協力いただきありがとうございます;あなたがあなたの答えを投稿するならば、私はこれを解決したとマークします。 –

+0

アクティビティを開くためにどのようなインテントパターンを使用しますか? AndroidManifest.xml(アクティビティが定義されている仕組み)でコードスニペット(アクティビティがどのように開かれるか)を投稿できますか? – yorkw

答えて

0

は、私は両方のゲームの存在を検出することによって、問題を「解決」する方法ですが、その後、デモ版をアンインストールするよう促す、誰もが将来に興味がある必要があります。

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メソッド。

0

デモ版とフルバージョンの間に別のパッケージを定義する必要があります。マニフェストには別のパッケージが定義されていても(同じパッケージでGoogle Playに2つのアプリを持つことはできないので必要です)、あなたが呼び出しているアクティビティもライブラリプロジェクトに存在していると仮定していますあなたのアプリの両方のバージョンのライブラリパッケージ。

これを回避するには、子プロジェクトのライブラリにあるマニフェストのすべてのアクティビティも宣言する必要があります。ここで

+0

私はパッケージの問題にぶつかりません。各アプリケーションには独自のパッケージが定義されています。 –

+0

ライブラリ内の共有アクティビティのパッケージを再定義していますか?またはライブラリパッケージを使用していますか。 –

+0

AndroidManifest.xmlの絶対パッケージパスをライブラリパッケージ内のアクティビティに置きます。 –