Fade current ActivityΒΆ

In this tutorial, you will learn how to fade the current Activity and launch a new one.

An Activity may launch a new Activity by using the Android API: startActivity() directly, without any fade out effect. Wave VR SDK provides the VRActivity function that can show a fade out effect before launching a new Activity:

public void doVRStartActivity(java.lang.Runnable)

Note

If doVRStartActivity() is used in the Java method, it may be called from the native code. Make sure doVRStartActivity() is executed in the main thread of VRActivity.

import com.htc.vr.sdk.VRActivity;
import java.lang.Runnable;
import android.content.Intent;

class MainActivity extends VRActivity {

    public void demo() {
        // Core process for using doVRStartActivity()
        Runnable runnable = new Runnable(){
            @Override
            public void run(){
                Intent intent = new Intent();
                intent.setClassName("demo.package","demo.class");
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
                                Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                // Start new activity by using Android APIs.
                startActivity(intent);
            }
        };
        doVRStartActivity(runnable);
    }
}