1

Possible Duplicate:
Requesting user to rate/review/comment on Android Market

I have developed and placed an application on the Android market. In its updated version, I want to add the functionality of Rating the App to the user.

I want the following functionality to the app:

  • As the user tries to exit from the app, one pop up will display to ask for rating the app. This pop up has three options: Yes, No and later
  • On selecting any option, the user will exit from the app.
  • If user select Yes then he will redirect to android market to rate this app. If user have rated the app once, then he will never show that pop up again.
  • If the user selects No, then the user will also not get this pop up again.
  • If the user selects 'Later' then pop up will be shown next time

I have problem in Yes option. How to manage, that user has given the rate once on `android market.

Is there any API which returns the information about the user rating?

Community
  • 1
  • 1
Manoj Agarwal
  • 703
  • 3
  • 17
  • 39
  • 2
    Why do you think your users will give you a positive rating when you attack them with popups when they try to leave your app? – CommonsWare Sep 10 '12 at 12:00
  • Yes CommonsWare. I can implement this anywhere in the app but question is how can I know that user has rated app or not? So I can apply logic that pop up will appear or not? – Manoj Agarwal Sep 10 '12 at 13:19
  • "how can I know that user has rated app or not?" -- you can't. "So I can apply logic that pop up will appear or not?" -- then do not use a popup. Having an action bar overflow menu item, or an entry in a settings activity, or something to lead the user to your Play Store entry so they can rate your app is reasonable. Attacking them with popups is far less reasonable. – CommonsWare Sep 10 '12 at 13:23

2 Answers2

0
using code on buttonclick listener   
 String App_Name="";
 bt.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
                      }});
mukesh
  • 4,140
  • 5
  • 29
  • 40
  • he wants to make sure the user has rated dont have any problem in going to the market – Athul Harikumar Sep 10 '12 at 12:12
  • not sure,until my app submit to android market.But Rating functionality handle by android market. try link http://www.androidsnippets.com/prompt-engaged-users-to-rate-your-app-in-the-android-market-appirater – mukesh Sep 10 '12 at 12:27
  • yap look at the question it says clearly to make sure the user rated and dont have any issue in going to the market – Athul Harikumar Sep 10 '12 at 12:28
  • Yes droidhot. I want exactly that. Can you please guide me ? – Manoj Agarwal Sep 10 '12 at 13:17
0

I think what you exactly want is this :

To test it and to tweak the dialog appearence, you can call AppRater.showRateDialog(this, null) from your Activity. Normal use is to invoke AppRater.app_launched(this) each time your activity is invoked (eg. from within the onCreate method). If all conditions are met, the dialog appears.

By the way, there is no API that gives you the information that the user rated it or not. Don't worry about it, he will use the never show this again option...

Another thing : you should prefer to show this at the beginning... When the user wants to leave, he mostly doesn't want to rate your app !

public class AppRater {
    private final static String APP_TITLE = "YOUR-APP-NAME";
    private final static String APP_PNAME = "YOUR-PACKAGE-NAME";

    private final static int DAYS_UNTIL_PROMPT = 3;
    private final static int LAUNCHES_UNTIL_PROMPT = 7;

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

    public static void showRateDialog(final Context mContext, final SharedPreferences.Editor editor) {
        final Dialog dialog = new Dialog(mContext);
        dialog.setTitle("Rate " + APP_TITLE);

        LinearLayout ll = new LinearLayout(mContext);
        ll.setOrientation(LinearLayout.VERTICAL);

        TextView tv = new TextView(mContext);
        tv.setText("If you enjoy using " + APP_TITLE + ", please take a moment to rate it. Thanks for your support!");
        tv.setWidth(240);
        tv.setPadding(4, 0, 4, 10);
        ll.addView(tv);

        Button b1 = new Button(mContext);
        b1.setText("Rate " + APP_TITLE);
        b1.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
                dialog.dismiss();
            }
        });        
        ll.addView(b1);

        Button b2 = new Button(mContext);
        b2.setText("Remind me later");
        b2.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                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();        
    }
}

source : link

Mathieu de Brito
  • 2,536
  • 2
  • 26
  • 30