The Problem with Flipulator Free
Recently, I found a AppRater class on StackOverflow and modified it to meet my needs. Once I reached the requisite number of launches over the requisite number of days, I get this dialog box:
The problem at this point is I always get this dialog each time I start the app. The best way for me to solve it is to troubleshoot the code.
A Closer Look
We have a RateThisApp class that has the onLaunch and showRateDialog methods. The onLaunch method uses the SharedPreferences class to store three pieces of data: dontshowagain, lLaunchCount and lDateFirstLaunch. The dontshowagain field is set to false initially. When set to true, you will not see the dialog again. The lLaunchCount field is set to 1. It will go up to the LAUNCHES_UNTIL_PROMPT field (set to 7). The lDateFirstLaunch field is set by the currentTimeMillis method in the System class. It will go up to the DAYS_UNTIL_PROMPT field (set to 3). The first check at the end of the method looks at the number of days since the first launch. The second check looks at the number of launches since the first launch. If both are true, the showRateDialog method starts.
The showRateDialog method initializes the Dialog that will be used. The Dialog will have a title and a LinearLayout. The LinearLayout will consist of a TextView and three Buttons. When the "Rate Flipulator Free" button is clicked, it takes you to the Google Play Store listing where you can rate it. When the "No, thanks" button is clicked, you will not see the dialog again. The problem lies within the "Rate Flipulator Free" and the "Remind me later" button listeners. When the "Rate Flipulator Free" button is clicked, you want to ensure that you do not see the dialog again once you rate it. When the "Remind me later" button is clicked, you want to reset the number of launches and number of days to zero. What you do is edit the snippet for the "Rate Flipulator Free" button listener to this:
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)));
if (editor != null) {
editor.putBoolean("dontshowagain", true);
editor.commit();
}
dialog.dismiss();
}
});
ll.addView(b1);
and the "Remind me later" button listener to this:
Button b2 = new Button(mContext);
b2.setText("Remind me later");
b2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (editor != null) {
editor.putLong("lLaunchCount", 0);
editor.putLong("lDateFirstLaunch", 0);
editor.commit();
}
dialog.dismiss();
}
});
ll.addView(b2);
You can also reset the data to test each case by going into your phone's application manager. Once in the application manager, find your app and click on "Clear Data." These changes will be applied to my Flipulator Premium app, which I expect will be published soon. Please stay tuned to this channel for more updates regarding this app as well as the Premium version which is coming soon to the Play Store.
No comments:
Post a Comment