我正在尝试将GDK示例罗盘项目(https://developers.google.com/glass/samples/gdk)从使用Livecard基础转换为沉浸/活动基础。我所做的一些更改包括以下内容:
任何人都有见解?
CompassMain.java
@Override
public void onStart(){
super.onStart();
// make view visible
setContentView(R.layout.compass);
// create renderer
CompassRenderer mRenderer = new CompassRenderer(this, mOrientationManager, mLandmarks);
// get handle to the surface view made visible above
CompassView surfaceView = (CompassView) findViewById(R.id.compass);
// magic
surfaceView.getHolder().addCallback(mRenderer);
// ensure the screen stays on
surfaceView.setKeepScreenOn(true);
}
CompassService.java
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (mLiveCard == null) {
mLiveCard = new LiveCard(this, LIVE_CARD_ID);
CompassRenderer mRenderer = new CompassRenderer(this, mOrientationManager, mLandmarks);
mLiveCard.setDirectRenderingEnabled(true).getSurfaceHolder().addCallback(mRenderer);
// Display specific card scroll view based on orientation
Intent menuIntent = new Intent(this, CompassMenuActivity.class);
menuIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
mLiveCard.setAction(PendingIntent.getActivity(this, 0, menuIntent, 0));
mLiveCard.attach(this);
mLiveCard.publish(PublishMode.REVEAL);
} else {
mLiveCard.navigate();
}
return START_STICKY;
}
答案 0 :(得分:2)
我得到了它的工作。以下是我所做的其他更改:
<强> CompassMain.java 强>
@Override
public void onStart(){
super.onStart();
// show the view and create the
setContentView(R.layout.compass);
CompassView compassView = (CompassView) findViewById(R.id.compass);
CompassRenderer mRenderer = new CompassRenderer(this, mOrientationManager, mLandmarks, compassView);
compassView.setWillNotDraw(false);
compassView.setKeepScreenOn(true);
compassView.getHolder().addCallback(mRenderer);
}
<强> CompassRenderer.java 强>
public CompassRenderer(Context context, OrientationManager orientationManager, Landmarks landmarks, CompassView compassView) {
LayoutInflater inflater = LayoutInflater.from(context);
mLayout = (FrameLayout) inflater.inflate(R.layout.compass, null);
mCompassView = compassView;
mOrientationManager = orientationManager;
mLandmarks = landmarks;
mCompassView.setOrientationManager(mOrientationManager);
}