How to know My Apps is used X time or X days android?
I want to show user a dailog box for rate my app on net if he likes. This dialog will ap开发者_如何学JAVApear if user has used(Viewed) my app X time or if the app is in his device for x days? .
I can use SharedPreferences on my splash screen and count each time app run. But I am wondering what if user not finish by pressing home. In this case the app will not launch. So what the solution?
I was thinking there may be a component for this,like IPhone AppRater. Please tell me if any. Or let me know how to do this.
Thanks
How about setting a counter (stored in SharedPreferences
) in onResume()
in your main activity?
And for the date, how about storing a date in SharedPreferences
if the date is not already set also in the onResume()
-method of your main activity?
And the check for displaying the Dialog-Box (linking into the market) I would also add to onResume()
.
onResume()
is only called if the user really sees your activity. Have a look here concerning the app lifecycle: http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle
精彩评论