package com.klaviar.bt200; import android.Manifest; import android.content.pm.PackageManager; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.util.Log; import com.wikitude.architect.ArchitectStartupConfiguration; import com.wikitude.architect.ArchitectView; import com.wikitude.architect.WearableArchitectView; import com.wikitude.common.camera.CameraSettings; import java.io.IOException; public class YourArActivity extends AppCompatActivity { private WearableArchitectView architectView; private String arExperience = "main/index.html"; private String song = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.your_ar_activity); song = getIntent().getExtras().getString("base64Midi", null); architectView = findViewById(R.id.wearableArchitectView); architectView.registerWorldLoadedListener(new ArchitectView.ArchitectWorldLoadedListener() { @Override public void worldWasLoaded(String s) { Log.d("Web", "Javascript call"); architectView.callJavascript("loadSong( '" + song + "' );"); } @Override public void worldLoadFailed(int i, String s, String s1) { //Todo Bei Fehlern erstmal laufen lassen } }); final ArchitectStartupConfiguration config = new ArchitectStartupConfiguration(); config.setLicenseKey(this.getString(R.string.wikitude_license_key)); config.setCameraPosition(CameraSettings.CameraPosition.BACK); config.setCameraResolution(CameraSettings.CameraResolution.AUTO); // The default resolution is 640x480. // config.setCameraFocusMode(sampleData.getCameraFocusMode()); // The default focus mode is continuous focusing. // config.setCamera2Enabled(false); // The camera2 api is disabled by default (old camera api is used). config.setFeatures(ArchitectStartupConfiguration.Features.ImageTracking); this.architectView.onCreate(config); } @Override protected void onPostCreate(@Nullable Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); architectView.onPostCreate(); if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 50); } try { this.architectView.load(arExperience); this.architectView.setStereoscopic3dDisplayModeEnabled(false); } catch (IOException e) { Log.e("KLAVIAR", "Exception while loading arExperience " + arExperience + ".", e); } } @Override protected void onResume() { super.onResume(); architectView.onResume(); // Mandatory ArchitectView lifecycle call // Enables stereoscopic rendering of the device. architectView.setStereoscopic3dDisplayModeEnabled(false); // Enables stereoscopic rendering of the ArchitectView. architectView.setStereoscopic3dRenderingEnabled(false); } @Override protected void onPause() { super.onPause(); // Disables stereoscopic rendering of the device. architectView.setStereoscopic3dDisplayModeEnabled(false); // Disables stereoscopic rendering of the ArchitectView. architectView.setStereoscopic3dRenderingEnabled(false); architectView.onPause(); // Mandatory ArchitectView lifecycle call } @Override protected void onDestroy() { super.onDestroy(); /* * Deletes all cached files of this instance of the ArchitectView. * This guarantees that internal storage for this instance of the ArchitectView * is cleaned and app-memory does not grow each session. * * This should be called before architectView.onDestroy */ architectView.clearCache(); architectView.onDestroy(); // Mandatory ArchitectView lifecycle call } }