1、需求
android我們知道經常會跳各種設置頁面,比如設置默認瀏覽器頁面、設置添加快捷方式權限頁面,我們會根據機型進行適配,但是有時候如果找到也找個頁面不try catch操作程序會奔潰
2、檢查跳轉的Activity是否存在代碼實現
public static boolean hasActivity(Context context, Intent intent) {if (context == null || intent == null) {return false;}PackageManager pm = context.getPackageManager();return pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0;}
3、測試代碼實現
public static void openMeizu(Activity context) {if (context == null) return;try {ComponentName componentName = null;Intent intent = new Intent("/");