0

私はAndroidアプリケーションに取り組んでいます。特定の数の起動に対して apprer ダイアログを開きたいです。そこで、次のコードを使用しました。

 public static void app_launched(Context mContext) {
    SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0);
    if (prefs.getBoolean("dontshowagain", false)) { return ; }

    SharedPreferences.Editor editor = prefs.edit();

    // Increment launch counter
    long launch_count = prefs.getLong("launch_count", 0) + 1;
    editor.putLong("launch_count", launch_count);

    // Get date of first launch
    Long date_firstLaunch = prefs.getLong("date_firstlaunch", 0);
    if (date_firstLaunch == 0) {
        date_firstLaunch = System.currentTimeMillis();
        editor.putLong("date_firstlaunch", date_firstLaunch);
    }

    // Wait at least n days before opening
    if (launch_count >= LAUNCHES_UNTIL_PROMPT) {
        if (System.currentTimeMillis() >= date_firstLaunch + 
                (DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000)) {
            showRateDialog(mContext, editor);
        }
    }

    editor.commit();
}   

それは正常に動作しています。しかし、私の問題は、LAUNCHES_UNTIL_PROMPT を 3 にすると、4 回目の起動時にダイアログが表示され、ユーザーが評価を与えた後、5 回ダイアログが起動することです。ダイアログが起動するたびに。そのため、ユーザーにとってはうんざりです。ユーザーがアプリを評価した場合、次のバージョンがリリースされるまで「アプリを評価する」必要はありません

PS: アプリの新しいバージョンがリリースされるたびに apprer を起動するために何かをすると便利です。

4

3 に答える 3

1

「今すぐ評価する」、「後で評価する」、「感謝しない」のオプションをダイアログに含めます。使用者が「今すぐ評価」をクリックした場合は、設定を更新して、ダイアログを再度表示しないようにします。彼らが「後で評価する」をクリックした場合は、カウントをリセットして、さらに 3 回起動した後に再度プロンプトを表示します。「いいえ」の場合は、設定を更新して、ダイアログを再度表示しないようにします。

于 2013-05-24T06:45:03.793 に答える
0

少し前にこの回答を見つけて、自分のアプリの 1 つで使用しましたが、あなたと同じ問題がありました。

showRateDialog 関数を次のように変更することをお勧めします。

    Button b1 = new Button(mContext);
    b1.setText("Rate " + APP_TITLE);
    b1.setOnClickListener(new OnClickListener() {
        // If Rate <your app> is selected, set dontshowagain field to true
        // and you will never see it again
        public void onClick(View v) {
            mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
            if (editor != null) {
                editor.putBoolean("dontshowagain", true);
                editor.commit();
            }
            dialog.dismiss();
        }
    });        
    ll.addView(b1);

    Button b2 = new Button(mContext);
    b2.setText("Remind me later");
    b2.setOnClickListener(new OnClickListener() {
        // If "Remind me later" is clicked, reset everything until requisite
        // number of launches or days since first launch
        public void onClick(View v) {
            if (editor != null) {
                editor.putLong("lLaunchCount", 0);
                editor.putLong("lDateFirstLaunch", 0);
                editor.commit();
            }
            dialog.dismiss();
        }
    });
    ll.addView(b2);

    Button b3 = new Button(mContext);
    b3.setText("No, thanks");
    b3.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (editor != null) {
                editor.putBoolean("dontshowagain", true);
                editor.commit();
            }
            dialog.dismiss();
        }
    });
    ll.addView(b3);

    dialog.setContentView(ll);        
    dialog.show();        
于 2016-05-05T13:50:57.407 に答える
0

ユーザーが Google Play でアプリを評価したかどうかを確認する方法はありません。開発者が特定のことを奨励するために使用する可能性があるためです。

于 2013-05-24T06:57:16.900 に答える