mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-20 13:06:05 +00:00
Android: add helper function to open an URL/URI (see bug 2783)
This commit is contained in:
parent
45c644cc99
commit
dd55bfe89c
3 changed files with 47 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue