0

I am working on an Android application. I want to open a apprater dialog for particular number of launches. So I used the following code.

 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();
}   

It is working fine.But my problem is if I give LAUNCHES_UNTIL_PROMPT is 3 then the dialog will appear on 4th launch and user gave his rating, then 5 time again dialog launches..every time the dialog launches. So it is disgusting for users. If the user rated the app then no need to 'rate the app' again until the next version relese

PS: It is helpful to do something to launch apprater whenever a new version of app is released.

sarath
  • 3,181
  • 7
  • 36
  • 58
  • I am not sure that it is possible, if there is some api which gives you a callback. For Google Plus, there are an api. You could check if users click "Yes" or "No", so if user will click yes, he will rate or No, mean not now and later. or you can see at socialize service – Daler May 24 '13 at 06:44

3 Answers3

1

Include options in the dialog to "rate now" "rate later" and "no thanks". If the use clicks "rate now" update preferences to not show the dialog again. If they click "rate later" simply reset your counts and prompt them again after another three launches. And if "no thanks" then simply update preferences to indicate the dialog should not be shown again.

Nelz11
  • 3,066
  • 1
  • 14
  • 20
  • I think you got my question wrong. My question is not about number of launches. Its about how can I prevent user from apprater dialog box if he already rate the app. – sarath May 24 '13 at 06:51
  • "But my problem is if I give LAUNCHES_UNTIL_PROMPT is 3 then the dialog will appear on 4th launch and user gave his rating, then 5 time again dialog launches..every time the dialog launches" You might want to edit this then, makes it sound like the problem is the rater launching on the fourth launch and all consecutive. – Nelz11 May 24 '13 at 06:56
  • Another SO question on play store api [here](http://stackoverflow.com/questions/12017291/is-there-an-official-api-for-the-google-play-store-app) There isn't a direct way to tell if they have rated... – Nelz11 May 24 '13 at 07:02
  • After understanding your question better I edited the previous answer since it had no relevance at all, sorry. – Nelz11 May 24 '13 at 07:12
  • If they click rate now and dont rate the app..then How can we identify that? – sarath May 24 '13 at 08:12
  • There isn't a way to do that directly. – Nelz11 Jun 05 '13 at 07:17
0

There is no way to check if a user has rated your app on Google Play, as developers may use it to incentivise certain things.

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
0

I found this answer some time ago and used it on one of my apps and had the same problem as yours.

I would suggest modifying your showRateDialog function to the following:

    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();        
Community
  • 1
  • 1
Daniel Burgner
  • 224
  • 2
  • 6
  • 16