mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-12-04 21:52:39 +00:00
Android: add helper function to open an URL/URI (see bug 2783)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user