我的第一个真正的android项目有问题。当客户端跟踪器确实识别目标时,我需要从那里开始一个新的活动。如果有人可以帮助我,对我来说意味着世界。
我已经尝试过的东西总是在灾难中结束......可能是因为我不知道我在做什么(这也是我没有发布我尝试过的原因)
P.S。我使用了Wikitude原生Api图书馆
package com.ia.grafp.maturapp2_2;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.ia.grafp.maturapp2_2.rendering.external.CustomSurfaceView;
import com.ia.grafp.maturapp2_2.rendering.external.Driver;
import com.ia.grafp.maturapp2_2.rendering.external.GLRenderer;
import com.wikitude.WikitudeSDK;
import com.wikitude.WikitudeSDKStartupConfiguration;
import com.wikitude.common.camera.CameraSettings;
import com.wikitude.common.rendering.RenderExtension;
import com.wikitude.common.tracking.RecognizedTarget;
import com.wikitude.rendering.ExternalRendering;
import com.wikitude.tracker.ClientTracker;
import com.wikitude.tracker.ClientTrackerEventListener;
import com.wikitude.tracker.Tracker;
/**
*/
public class ArchitectView extends AppCompatActivity implements ClientTrackerEventListener, ExternalRendering {
private static final String TAG = "ArchitectView";
private WikitudeSDK _wikitudeSDK;
private CustomSurfaceView _view;
private Driver _driver;
private GLRenderer _glRenderer;
private boolean tracking;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
_wikitudeSDK = new WikitudeSDK(this);
WikitudeSDKStartupConfiguration startupConfiguration
= new WikitudeSDKStartupConfiguration
(WikitudeSDKConstants.WIKITUDE_SDK_KEY,
CameraSettings.CameraPosition.BACK,
CameraSettings.CameraFocusMode.CONTINUOUS);
_wikitudeSDK.onCreate(getApplicationContext(), this, startupConfiguration);
ClientTracker tracker
= _wikitudeSDK.getTrackerManager().create2dClientTracker
("file:///android_asset/magazine.wtc");
tracker.registerTrackerEventListener(this);
}
@Override
protected void onResume() {
super.onResume();
_wikitudeSDK.onResume();
_view.onResume();
_driver.start();
}
@Override
protected void onPause() {
super.onPause();
_wikitudeSDK.onPause();
_view.onPause();
_driver.stop();
}
@Override
protected void onDestroy() {
super.onDestroy();
_wikitudeSDK.onDestroy();
}
@Override
public void onRenderExtensionCreated(final RenderExtension renderExtension_) {
_glRenderer = new GLRenderer(renderExtension_);
_view = new CustomSurfaceView(getApplicationContext(), _glRenderer);
_driver = new Driver(_view, 30);
setContentView(_view);
}
@Override
public void onExtendedTrackingQualityUpdate(final Tracker tracker_, final String targetName_, final int oldTrackingQuality_, final int newTrackingQuality_) {
}
@Override
public void onErrorLoading(final ClientTracker clientTracker_, final String errorMessage_) {
Log.v(TAG, "onErrorLoading: " + errorMessage_);
}
@Override
public void onTrackerFinishedLoading(final ClientTracker clientTracker_, final String trackerFilePath_) {
}
@Override
public void onTargetRecognized(final Tracker tracker_, final String targetName_) {
}
@Override
public void onTracking(final Tracker tracker_, final RecognizedTarget recognizedTarget_) {
_glRenderer.setCurrentlyRecognizedTarget(recognizedTarget_);
}
@Override
public void onTargetLost(final Tracker tracker_, final String targetName_) {
_glRenderer.setCurrentlyRecognizedTarget(null);
}
}
答案 0 :(得分:0)
@Override
public void onTargetRecognized(final Tracker tracker_, final String targetName_) {
Intent i = new Intent(ArchitectView.this, yourActivityClass.class);
startactivity(i);
}
我不知道这是否能回答你的问题,但这是开展新活动的方式。