Reprint please indicate the source: Wang 亟亟 's way of Daniel
Recently soft article writing less, the family's baby (wheat) bite hair, in careful care. Plus recently played Wow compared to the top, so did not spend much time in writing articles, today see an implementation of the app in the prompt to jump application Market Library feel good, recommend to everyone
Let's take a look at the running effect
User points in He will ask whether rating, later evaluation and so on, the original author of this series of functional seal more thorough, convenient for everyone to use, we look at a simple hint page how to configure.
Set up something that needs to be configured during the activity initialization phase.
Apprate.with ( This). Setstoretype (Storetype.googleplay)//default Google, and another one is Amazon. Setinstalldays (0)//Default 10, here to demonstrate the effect, set the load when the demo. Setlaunchtimes (3)//Set the start time. Setremindinterval (2)//Interval of reminders. Setshowlaterbutton (true)//Whether to show the postpone button. Setdebug (false)//Whether the debug state, default false. Setmessage ("Share us, okay?")//Set Description text. Setonclickbuttonlistener (NewOnclickbuttonlistener () {//Button listener events @Override Public void OnClickButton(intwhich) {LOG.D (MainActivity.class.getName (), integer.tostring (which)); }}). monitor ();
Show him where it needs to show.
// 显示对话框 AppRate.showRateDialogIfMeetsConditions(this);
Of course, you can set the title or something like this.
setTitle()//设置标题setNeutralText()//设置按钮文字内容
Of course, you think this UI you do not like, you have to conform to your company's graphic design, also OK
Call the Setview method, like this
LayoutInflater inflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);View view = inflater.inflate(R.layout.custom_dialog, (ViewGroup)findViewById(R.id.layout_root));AppRate.with(this).setView(view).monitor();
The above is the basic settings, next is the place where the egg hurts, the author must not be Chinese, so there is no such a complicated market issue, and we can not goolgle Play, so the default mode we can not use, so this is why I did not post the reason, because we have to modify.
OK, let's talk about where to change.
The source is so long
To share the URL action is
Urihelper
Intenthelper
Storetype
Dialogmanager
Storetype is an enumeration type that distinguishes which market we are, and if you are going to millet, go to the pea pod and add it inside.
publicenum StoreType { GOOGLEPLAY, AMAZON//, 你要的内容}
Intenthelper is where you specifically pass intent.
FinalClass Intenthelper {Private Static FinalString Google_play_package_name ="Com.android.vending";Private Intenthelper() { }StaticIntent Createintentforgoogleplay (Context context) {String PackageName = Context.getpackagename (); Intent Intent =NewIntent (Intent.action_view, Getgoogleplay (PackageName));if(Ispackageexists (context, google_play_package_name)) {intent.setpackage (google_play_package_name); }returnIntent }StaticIntent Createintentforamazonappstore (Context context) {String PackageName = Context.getpackagename ();return NewIntent (Intent.action_view, Getamazonappstore (PackageName)); }}
Urihelper do some URL splicing processing
FinalClass Urihelper {Private Static FinalString Google_play ="Https://play.google.com/store/apps/details?id=";Private Static FinalString Amazon_appstore ="amzn://apps/android?p=";Private Urihelper() { }StaticUri Getgoogleplay (String packagename) {returnPackageName = =NULL?NULL: Uri.parse (Google_play + packagename); }StaticUri Getamazonappstore (String packagename) {returnPackageName = =NULL?NULL: Uri.parse (Amazon_appstore + packagename); }Static BooleanIspackageexists (context context, String targetpackage) {Packagemanager pm = Context.getpackagemanager (); list<applicationinfo> packages = Pm.getinstalledapplications (0); for(ApplicationInfo packageinfo:packages) {if(PackageInfo.packageName.equals (Targetpackage))return true; }return false; }}
This is all done with the code in Dialogmanager.
Builder.setpositivebutton (Options.getpositivetext (context), Span class= "Hljs-keyword" >new Dialoginterface.onclicklistener () { @Overrid E public void onclick (Dialoginterface dialog, int which) {final Intent intenttoappstore = options.getstoretype () = = Storetype.googleplay? Createintentforgoogleplay (context): Createintentforamazonappstore (context); Context.startactivity (Intenttoappstore); Setagreeshowdialog (context, false ); if (Listener! = null ) Listener.onclickbutton (which); } });
The default after you click on the evaluation will determine which store you are, you add in the OnClick method is good
This control has been added to the grand package, Amway as follows: HTTPS://GITHUB.COM/DDWHAN0123/USEFUL-OPEN-SOURCE-ANDROID/BLOB/MASTER/README.MD
Git:https://github.com/hotchemi/android-rate
: Https://github.com/hotchemi/Android-Rate/archive/master.zip
Turn git---Simple configuration to achieve product in the application market evaluation jump function