Android download starts QQ browser by default
// Built-in QQ Browser
// Add the following function to the first activity started by the Program:
// Set the default browser to QQ.
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 of the default item. When your operations comply with this filter, the default setting takes effect.
IntentFilter filter = new IntentFilter (str3 );
Filter. addCategory (str1 );
Filter. addCategory (str2 );
Filter. addDataScheme ("http ");
// Key settings: QQ browsing: 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 all browser programs currently installed on the mobile phone
List 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 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 the Function
}