Forum Discussion
Justbrave
8 years agoHonored Guest
Samsung Internet in VR mode with Intent
Hello,
I would like to open Samsung Internet Browser in VR from my Unity App. I wrote a code which opens the browser but the URL doesn't load. In that code I use "com.sec.android.app.svrbrowser" to identify the application.
If I use "com.sec.android.app.sbrowser" without vr and without VR mode (so a normal appplication) then the normal browser opens and loads my URL.
So my problem is that I want to open the VR browser with a specific URL, not in blank.
I would appreciate it any help. Thanks.
The code:
{
I would like to open Samsung Internet Browser in VR from my Unity App. I wrote a code which opens the browser but the URL doesn't load. In that code I use "com.sec.android.app.svrbrowser" to identify the application.
If I use "com.sec.android.app.sbrowser" without vr and without VR mode (so a normal appplication) then the normal browser opens and loads my URL.
So my problem is that I want to open the VR browser with a specific URL, not in blank.
I would appreciate it any help. Thanks.
The code:
{
bool fail = false;
string bundleId = "com.sec.android.app.svrbrowser"; // your target bundle id
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
AndroidJavaClass intentStaticClass = new AndroidJavaClass("android.content.Intent");
AndroidJavaClass packageManagerStaticClass = new AndroidJavaClass("android.content.pm.PackageManager");
AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", url);
AndroidJavaObject launchIntent = null;
try
{
launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", bundleId);
launchIntent.Call<AndroidJavaObject>("setAction", "android.intent.action.SBROWSER_VIEW_FOR_EXTERNAL_APP");
launchIntent.Call<AndroidJavaObject>("setData", uriObject);
launchIntent.Call<AndroidJavaObject>("setPackage", bundleId);
}
catch (System.Exception e)
{
fail = true;
}
if (fail)
{ //open app in store
Application.OpenURL(bundleId);
}
else
{//open the app
ca.Call("startActivity", launchIntent);
}
up.Dispose();
ca.Dispose();
packageManager.Dispose();
launchIntent.Dispose();
intentStaticClass.Dispose();
uriClass.Dispose();
uriObject.Dispose();
}
}
1 Reply
Replies have been turned off for this discussion
- paw9kProtegehow about if we tried to do this with the Oculus browser that is now built into Oculus Home?
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 4 years ago