Web Task Dialogs
Native VR applications can launch lightweight browser windows called Web Tasks. A Web Task is a modal browser window with a toolbar that contains a back button, refresh button, web security information, a read-only address bar, and a Done button.
Web Tasks provide a similar experience as Chrome Custom Tabs on Android, but are specialized for VR. They are great for linking to external information, such as a privacy policy or support documentation, as well as web-based authentication flows such as OAuth.
The following image shows an example of the Web Task window.
To launch Browser as a Web Task, create a new intent and pass the URI to the Web Task.
Java example:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("ovrweb://webtask?uri=" + Uri.encode(url)));
mContext.startActivity(intent);
Note: Under memory pressure, it is possible the app that launched the Web Task can be terminated while in the background.
A Web Task can be closed in one of three ways:
- By the user, when they click the DONE button. The OS returns to the app that launched the Web Task.
- By the web page, if it calls the
window.close()
function (JavaScript) to close the current window. - By the web page, if it navigates to an app intent scheme (For example,
mygame://
), the browser asks the user if they wish to switch to another app. If the user agrees, the OS activates the app’s intent.
Using Web Tasks for Authentication (OAuth)
Web Tasks can be used for authentication flows for your app. The following steps provide a typical authentication flow.
The URL opened by the Web Task should point to a login flow that ends in an intent launch. For most OAuth flows, this means you should provide your app’s intent scheme as the redirect URI parameter in the login service URL.
Register for the intent scheme in your app.
Example intent registration:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="mygame" />
</intent-filter>
As a result, the web login service launches your app (optionally, with an auth token) after the user has logged in: