Android download default startup QQ browser

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.