List of usage examples for android.view View callOnClick
public boolean callOnClick()
From source file:com.google.vr.sdk.samples.video360.VideoActivity.java
/** * Checks that the appropriate permissions have been granted. Otherwise, the sample will wait * for the user to grant the permission. * * @param savedInstanceState unused in this sample but it could be used to track video position *///from w ww .ja v a 2 s. co m @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.video_activity); // Configure the MonoscopicView which will render the video and UI. videoView = (MonoscopicView) findViewById(R.id.video_view); VideoUiView videoUi = (VideoUiView) findViewById(R.id.video_ui_view); videoUi.setVrIconClickListener(new OnClickListener() { @Override public void onClick(View v) { // Convert the Intent used to launch the 2D Activity into one that can launch the VR // Activity. This flow preserves the extras and data in the Intent. DaydreamApi api = DaydreamApi.create(VideoActivity.this); if (api != null) { // Launch the VR Activity with the proper intent. Intent intent = DaydreamApi .createVrIntent(new ComponentName(VideoActivity.this, VrVideoActivity.class)); intent.setData(getIntent().getData()); intent.putExtra(MediaLoader.MEDIA_FORMAT_KEY, getIntent().getIntExtra(MediaLoader.MEDIA_FORMAT_KEY, Mesh.MEDIA_MONOSCOPIC)); api.launchInVr(intent); api.close(); } else { // Fall back for devices that don't have Google VR Services. This flow should only // be used for older Cardboard devices. Intent intent = new Intent(getIntent()).setClass(VideoActivity.this, VrVideoActivity.class); intent.removeCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(0); // Clear any flags from the previous intent. startActivity(intent); } // See VrVideoActivity's launch2dActivity() for more info about why this finish() call // may be required. finish(); } }); videoView.initialize(videoUi); // Boilerplate for checking runtime permissions in Android. if (ContextCompat.checkSelfPermission(this, permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { View button = findViewById(R.id.permission_button); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ActivityCompat.requestPermissions(VideoActivity.this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, READ_EXTERNAL_STORAGE_PERMISSION_ID); } }); // The user can click the button to request permission but we will also click on their behalf // when the Activity is created. button.callOnClick(); } else { // Permission has already been granted. initializeActivity(); } }