Originally thought that the application score is a very small function, but the realization only then discovered really is not a trivial matter. Online search data did not find the answer, in a lot of development group asked a lot of people did not solve the problem, the final analysis of log, anti-compilation to see the source finally have some clues, OK, on the code:
1 try{2 uri uri = uri.parse ("market://details?id=" +getpackagename ()); 3 Intent Intent = new Intent (Intent.action_view,uri); 4 intent.addflags (intent.flag_activity_new_task); 5 startactivity (intent); 6}catch (Activitynotfoundexception e) {7 Toast.maketext (context, "couldn ' t launch The market! ", Toast.length_short). Show (); 8}
And in the test found in some wonderful do not install the application market phone above will appear directly out of the application of the bug, so the exception has been processed, and now finally solve the problem perfectly ~
on the HTC phone will default to the HTC Mall, you can force change the jump method, let the app jump to 360 market, the code is as follows: Intent Intent = new Intent (intent.action_view);// Jump to 360 market rating ComponentName CN = new ComponentName ("Com.qihoo.appstore", " Com.qihoo.appstore.activities.SearchDistributionActivity "); Intent.setcomponent (CN); Intent.setdata (Uri.parse (" Market://details?id=com.xiaoma.tuofu ") startactivity (intent); //determine if the market exists method public static Boolean isavilible (context context, String PackageName) { final Packagemanager Packagemanager = Context.getpackagemanager ();// Get packagemanager list< packageinfo> pinfo = packagemanager.getinstalledpackages (0);//Get package information for all installed programs list<string> pName = new arraylist<string> ();// Package name for storing all installed programs //Remove package name from pinfo, press into PName list if (pinfo! = null) { for (int i = 0; i < pinfo.size (); i++) { String pn = pinfo.get (i) .packagename; & nbsp Pname.add (PN); } &NBS P } return pname.contains (PackageName);//Determine if there is a package name for the target program in PName, there is true, no false }//determine if the 360 market exists if (geturi.isavilible (appsactivity.this, "Com.qihoo.appstore")) {//Market exists}else{//market does not exist}
/********************************* Gorgeous split line ********************************************/public void Test (View v) {// Determine if the 360 market exists if (isavilible (My.this, "Com.qihoo.appstore")) {//market exists intent Intent = new Intent (Intent.action_view) ;//Jump to 360 market ratings componentname CN = new ComponentName ("Com.qihoo.appstore", " Com.qihoo.appstore.activities.SearchDistributionActivity "); Intent.setcomponent (CN); Intent.setdata (Uri.parse (" Market://details?id=com.paopaobeauty.meinv ")); StartActivity (intent);} else {//market does not exist Toast.maketext (Getapplicationcontext (), "Please download 360 phone assistant", 0). Show ();}} //The method of judging whether the market exists public static Boolean isavilible (context context, String PackageName) {final Packagemanager Packagemanager = Context.getpackagemanager ();//get packagemanagerlist<packageinfo> pinfo = Packagemanager.getinstalledpackages (0);//Get package information for all installed programs list<string> pName = new arraylist<string> ();// The package name used to store all installed programs//Remove the package name from pinfo, press into the PName list if (pinfo! = null) {for (int i = 0; i < pinfo.size (); i++) {String pn = pinfo.get (i). Packagename;pname.add (PN);}} Return Pname.contains (PackageName);//Determine if there is a package name for the target program in PName, there is true, there is no false}
Android in the jump market scoring problem summary