Android獲取默認瀏覽器信息

cey6 9年前發布 | 2K 次閱讀 Java Android

Android系統可以用如下方法獲取默認瀏覽器信息:

public static ActivityInfo getBrowserApp(Context context) { String default_browser = "android.intent.category.DEFAULT"; String browsable = "android.intent.category.BROWSABLE"; String view = "android.intent.action.VIEW";

    Intent intent = new Intent(view);
    intent.addCategory(default_browser);
    intent.addCategory(browsable);
    Uri uri = Uri.parse("http://");
    intent.setDataAndType(uri, null);


    // 找出手機當前安裝的所有瀏覽器程序
    List<ResolveInfo> resolveInfoList = context.getPackageManager().queryIntentActivities(intent, PackageManager.GET_INTENT_FILTERS);
    if (resolveInfoList.size() > 0) {
        ActivityInfo activityInfo = resolveInfoList.get(0).activityInfo;
        String packageName = activityInfo.packageName;
        String className = activityInfo.name;
        return activityInfo;
    } else {
        return null;
    }
}</pre> 


 本文由用戶 cey6 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!