我在通过意图启动活动时遇到了这个问题。问题是,如果我进入我的XML,并将AugmentedReality设置为主要Activity(以及作为第一个启动的那个),那么基本上没有问题
<activity android:name=".AugmentedReality" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
应用程序将在相机预览上绘制一个立方体,但之后我不会“访问”我的其他活动“Location”,“DescriptionText”和“Description”。如果我将Location活动作为我的XML文件中的主要活动,然后按下将我带到AugmentedReality活动的按钮,我看不到绘制的多维数据集(我使用了Log.v(TAG, "Cube drawn");
,并且得到了垃圾邮件)。
我正在使用此代码声明并从我的Location类发送intent
public class Language extends Activity implements OnClickListener
:
`if (dButton.isPressed()) {
description = dbh.getDescription("Danish");
list = dbh.getGPS("Maribo");
f = new float[list.size()];
for (int i = 0; i < list.size(); i++) {
f[i] = list.get(i);
}
intent = new Intent(this, Description.class);
try {
startActivity(intent);
} catch (ActivityNotFoundException ex) {
}
}`
当我按下dButton时,我被发送到我的AugmentedReality活动,该活动仅显示相机预览。而不是立方体。这是AugmentedReality中的onCreate方法
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
camview = new CameraView(this);
graphics = new GraphicsView(this);
final Window win = getWindow();
requestWindowFeature(Window.FEATURE_NO_TITLE);
win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(graphics);
addContentView(camview, new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
Log.v("AR", "Content sat");
}
GraphicsView中的onSurfaceChanged:
public void onDrawFrame(GL10 gl) {
gl.glDisable(GL10.GL_DITHER);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
// GLU.gluLookAt(gl, coords[0], coords[1], 0, 0, 0, 0,
// orientation[0],
// orientation[1], orientation[2]);
GLU.gluLookAt(gl, 0, 0, -5, 0, 0, 0, 0, 2, 0);
gl.glRotatef(45, 45, 0, 15);
cube.draw(gl);
当然还有我的Cube类中的draw方法:
public void draw(GL10 gl) {
gl.glFrontFace(GL10.GL_CW);
gl.glEnable(GL10.GL_CULL_FACE);
gl.glCullFace(GL10.GL_BACK);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, verticesBuffer);
gl.glDrawElements(GL10.GL_TRIANGLES, indices.length,
GL10.GL_UNSIGNED_SHORT, indicesBuffer);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDisable(GL10.GL_CULL_FACE);
}
我希望有人可以告诉我为什么只有在我的XML文件中将AugmentedReality设置为main时才能看到多维数据集。相机已获得XML文件中的所有必需权限,并且Location类已获得使用GPS的权限
答案 0 :(得分:0)
您是否在Manifest文件中映射了Description类?即使您已映射,您也需要提供权限
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-feature android:name="android.hardware.camera"/>
<activity android:name=".Description"/>
答案 1 :(得分:0)
感谢有关解决方案的建议。
我已经通过改变
解决了这个问题setContentView(graphics);
addContentView(camView, new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
到
setContentView(camview);
addContentView(graphics, new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
camView是我的Camera实例的一个对象,图形是我的OpenGLES 1.0的一个对象。这是奇怪的事情:我已经厌倦了几次与图形和逆向交换camView。但无论如何:它现在正在工作