Created
July 19, 2021 14:59
-
-
Save t4kemyh4nd/5add2336de85c5f19cebad11b914762d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Intent parseActivity(Context context, Uri uri) { | |
if (uri == null || !FeatureConstants.SCHEME.equals(uri.getScheme())) { | |
return null; | |
} | |
String authority = uri.getAuthority(); | |
IDeviceCompat deviceCompat = IApplicationHelper.CC.getInstance().getDeviceCompat(); | |
if ("settings".equals(authority)) { | |
Intent intent = new Intent(context, deviceCompat.getActivityClass(1)); | |
intent.setData(uri); | |
intent.setPackage(context.getPackageName()); | |
return intent; | |
} else if ("web".equals(authority)) { | |
boolean booleanQueryParameter = uri.getBooleanQueryParameter(FeatureConstants.PARAM_BROWSER_VIEW, false); | |
String queryParameter = uri.getQueryParameter("url"); | |
if (!booleanQueryParameter || TextUtils.isEmpty(queryParameter)) { | |
return null; | |
} | |
return new Intent("android.intent.action.VIEW", Uri.parse(queryParameter)); | |
} else if (!FeatureConstants.AUTHORITY_OUT_BROWSER.equals(authority)) { | |
return null; | |
} else { | |
Intent intent2 = new Intent("android.intent.action.VIEW", Uri.parse(uri.getQueryParameter("url"))); | |
intent2.setFlags(268435456); | |
String queryParameter2 = uri.getQueryParameter(FeatureConstants.PARAM_PACKAGE); | |
if (!TextUtils.isEmpty(queryParameter2)) { | |
intent2.setPackage(queryParameter2); | |
} | |
if (!Utils.isIntentExist(context, intent2)) { | |
intent2.setPackage(null); | |
} | |
return intent2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment