我的应用程序即将关闭,但是很奇怪,因为我正处于开发初期,因此该应用程序没有什么特别之处!
我的第一堂课:
package it.mi.action.codmmunicator_2ddecoder;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class Loading extends Activity {
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.loading);
final int tempodiattesa=3000;
Thread schermataattesa=new Thread(){
int aspetta=0;
@Override
public void run(){
try{
super.run();
while(aspetta<tempodiattesa){
sleep(100);
aspetta+=100;
}
}catch(Exception e){
System.out.println("EXc="+e);
}finally{
startActivity(new Intent(Loading.this,Lettore.class));
finish();
}
}
};
schermataattesa.start();
}
}
第二个:
package it.mi.action.codmmunicator_2ddecoder;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class Lettore extends Activity {
@Override
public void onCreate(Bundle savedInstanceState){
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.lettore);
}
}
当它进行第二节课时,它崩溃了。
xml是带有图像的普通线性布局。
我确定android清单正确:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="it.mi.action.codmmunicator_2ddecoder" android:versionCode="1" android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.CAMERA"/>
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
<activity android:name="Loading" android:label="@string/app_name" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Lettore" android:screenOrientation="portrait" android:label="@string/app_name"></activity>
</application>
</manifest>
如果我让应用程序以Lettore开头,则会崩溃。我认为问题出在Lettore.java上,但这很荒谬
有人能帮我吗?
看到那不正常吗?
,这是我的日志:
06-28 13:41:25.322: D/dalvikvm(403): GC_EXTERNAL_ALLOC freed 51K, 53% free 2552K/5379K, external 716K/1038K, paused 61ms
06-28 13:41:29.353: D/AndroidRuntime(403): Shutting down VM
06-28 13:41:29.353: W/dalvikvm(403): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-28 13:41:29.363: E/AndroidRuntime(403): FATAL EXCEPTION: main
06-28 13:41:29.363: E/AndroidRuntime(403): android.app.SuperNotCalledException: Activity {it.mi.action.codmmunicator_2ddecoder/it.mi.action.codmmunicator_2ddecoder.Lettore} did not call through to super.onCreate()
06-28 13:41:29.363: E/AndroidRuntime(403): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1613)
06-28 13:41:29.363: E/AndroidRuntime(403): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-28 13:41:29.363: E/AndroidRuntime(403): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-28 13:41:29.363: E/AndroidRuntime(403): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-28 13:41:29.363: E/AndroidRuntime(403): at android.os.Handler.dispatchMessage(Handler.java:99)
06-28 13:41:29.363: E/AndroidRuntime(403): at android.os.Looper.loop(Looper.java:123)
06-28 13:41:29.363: E/AndroidRuntime(403): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-28 13:41:29.363: E/AndroidRuntime(403): at java.lang.reflect.Method.invokeNative(Native Method)
06-28 13:41:29.363: E/AndroidRuntime(403): at java.lang.reflect.Method.invoke(Method.java:507)
06-28 13:41:29.363: E/AndroidRuntime(403): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-28 13:41:29.363: E/AndroidRuntime(403): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-28 13:41:29.363: E/AndroidRuntime(403): at dalvik.system.NativeStart.main(Native Method)
06-28 13:41:32.083: I/Process(403): Sending signal. PID: 403 SIG: 9
我确定android清单正确:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="it.mi.action.codmmunicator_2ddecoder" android:versionCode="1" android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.CAMERA"/>
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
<activity android:name="Loading" android:label="@string/app_name" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Lettore" android:screenOrientation="portrait" android:label="@string/app_name"></activity>
</application>
</manifest>
如果我让应用程序以Lettore开头,则会崩溃。我认为问题出在Lettore.java上,但这很荒谬
最佳答案
super.onCreate() is missing in Lettore class
..
public void onCreate(Bundle savedInstanceState){
super.onCreate(); //<-----------------------------add this
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.lettore);
}
1-确认您是否已将Lettore的条目放入清单中。