Built-in QQ browser
Add the following function to the first activity in the program startup
Set system default browser is QQ browser
private void Setbroser () {
Packagemanager Packagemanager = This.getpackagemanager ();
String str1 = "Android.intent.category.DEFAULT";
String str2 = "Android.intent.category.BROWSABLE";
String STR3 = "Android.intent.action.VIEW";
Set one of the required parameters for the default item, the default setting works when the user's action conforms to the filter
Intentfilter filter = new Intentfilter (STR3);
Filter.addcategory (STR1);
Filter.addcategory (STR2);
Filter.adddatascheme ("http");
Key Settings QQ Browse: Package Name: COM.TENCENT.MTT, class name: Com.tencent.mtt.MainActivity
ComponentName component = new ComponentName ("COM.TENCENT.MTT",
"Com.tencent.mtt.MainActivity");
Intent Intent = new Intent (STR3);
Intent.addcategory (STR2);
Intent.addcategory (STR1);
Uri uri = Uri.parse ("http://");
Intent.setdataandtype (URI, NULL);
Find out all browser programs currently installed on your phone
list<resolveinfo> resolveinfolist = Packagemanager
. Queryintentactivities (Intent,
Packagemanager.get_intent_filters);
int size = Resolveinfolist.size ();
componentname[] Arrayofcomponentname = new Componentname[size];
for (int i = 0; i < size; i++) {
Activityinfo Activityinfo = Resolveinfolist.get (i). Activityinfo;
String PackageName = activityinfo.packagename;
String className = activityinfo.name;
Clear the previous default settings
Packagemanager.clearpackagepreferredactivities (PackageName);
ComponentName componentname = new ComponentName (PackageName,
ClassName);
Arrayofcomponentname[i] = componentname;
}
Packagemanager.addpreferredactivity (Filter,
Intentfilter.match_category_scheme, Arrayofcomponentname,
component);
}
Call
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
Setbroser ();//Call function
}
Android download default startup QQ browser