Android: add helper function to open an URL/URI (see bug 2783)

This commit is contained in:
Sylvain Becker
2020-10-01 14:41:09 +02:00
parent 45c644cc99
commit dd55bfe89c
3 changed files with 47 additions and 0 deletions

View File

@@ -1588,6 +1588,30 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
nativePermissionResult(requestCode, false);
}
}
/**
* This method is called by SDL using JNI.
*/
public static int openURL(String url)
{
try {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
if (Build.VERSION.SDK_INT >= 21) {
flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
} else {
flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
}
i.addFlags(flags);
mSingleton.startActivity(i);
} catch (Exception ex) {
return -1;
}
return 0;
}
}
/**