mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 06:37:30 +00:00
Explicitly add http scheme if missing. Fixes austinhuang0131/barinsta#1642
This commit is contained in:
parent
6ae5d8bd59
commit
b4d3709da5
@ -195,10 +195,15 @@ public final class Utils {
|
|||||||
if (context == null || TextUtils.isEmpty(url)) {
|
if (context == null || TextUtils.isEmpty(url)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
try {
|
||||||
|
String url1 = url;
|
||||||
|
// add http:// if string doesn't have http:// or https://
|
||||||
|
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
||||||
|
url1 = "http://" + url;
|
||||||
|
}
|
||||||
|
final Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url1));
|
||||||
i.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
|
i.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
|
||||||
i.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
|
i.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
|
||||||
try {
|
|
||||||
context.startActivity(i);
|
context.startActivity(i);
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
Log.e(TAG, "openURL: No activity found to handle URLs", e);
|
Log.e(TAG, "openURL: No activity found to handle URLs", e);
|
||||||
|
Loading…
Reference in New Issue
Block a user