我正在尝试在 Eclipse 中(在 Windows 中)制作一个 android 游戏。当我在模拟器和手机上运行我的程序时,我不断收到 nulpointerexceptions 和 classcastexceptions。我有 2 个类(活动),每个类都有自己的 xml 布局。主要活动完美运行。但是,当我启动第二个活动时:
final Intent i = new Intent(this, Arrowscreen.class);
...
startActivity(i);
我得到了前面提到的例外。它始终指向未找到的源。 无论如何在windows中通过eclipse中的源代码?我看过http://source.android.com,但似乎没有适用于 windows 的解决方案。我尝试按照 cygwin 的 linux 指令进行操作,但它似乎不起作用(如果可能的话,我更喜欢在 Windows 中工作)。
我还是 android 开发的新手,所以我可能会遗漏一些重要的东西。这个清单声明有什么问题吗?:
<activity android:name=".Arrowscreen"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.RUN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
我将避免发布我的整个代码示例,因为它很长,但我会告诉你它使用加速度计、gps 和一个可运行的用于带有“postDelayed”的计时器上的主循环。gps 精细定位权限也在清单中。我被卡住了,所以任何帮助将不胜感激。谢谢!
编辑:以下是我得到运行时异常的代码部分
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.arrow);
img=(ImageView)findViewById(R.id.ArrowBackground);
arrow1=(ImageView)findViewById(R.id.turningArrow);
GPSx=(TextView)findViewById(R.id.textView1);
GPSy=(TextView)findViewById(R.id.textView2);
MGNTx=(TextView)findViewById(R.id.textView3);
MGNTy=(TextView)findViewById(R.id.textView4);
angle = 0;
lastAngle = 0;
arrowAngle = 0;
mValues[0]=0; mValues[1]=0; mValues[2]=0;
//mStartTime = System.currentTimeMillis();
mHandler.removeCallbacks(UpdateArrow);
mHandler.postDelayed(UpdateArrow, 400);