startActivity(背景下,A类)功能不能正常工作
问题描述:
我有这个问题,同时开始通过intents.The问题的活动是,如果我去到我的XML,并将增强现实为主要活动(和一个即将推出作为第一个),基本上没有问题。startActivity(背景下,A类)功能不能正常工作
<activity android:name=".AugmentedReality" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
的应用将借助摄像头预览立方体,但我不会“访问”我的其他活动的“位置”,“descriptiontext描述”和“说明”。如果我继续在我的XML文件中的主要活动位置的活动,然后按该带我到增强现实活动按钮,我无法看到的立方体,它被绘制(我用Log.v(TAG, "Cube drawn");
,并得到了垃圾邮件)。
我使用这个代码来声明,并从我的位置类 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,我发到我的扩增实境活动,这仅是显示相机预览。而不是立方体。下面是增强现实
的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");
}
的onSurfaceChanged在GraphicsView:
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);
,当然还有我的魔方类里面的绘制方法:
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文件中所要求的权限,而位置类已经得到了使用GPS
答
感谢您提出有关解决方案的建议。
我已经从
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是我的相机实例的对象,图形是我的OpenGLES 1.0的对象。这是奇怪的事情:我已经厌倦了几次用图形交换camView和逆向。但不管怎么说:它的工作现在
答
你有没有在清单文件映射说明类许可?即使你映射你也需要给予许可
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-feature android:name="android.hardware.camera"/>
<activity android:name=".Description"/>
这是我的XML文件中太: – Zuenonentu 2012-02-17 13:44:23
请把相机许可清单文件,看到上面的代码 – Bamadeva 2012-02-17 13:51:24