Skip to main content
 首页 » 编程设计

Android:应用程序意外关闭,但这太奇怪了

2024年02月20日10lautakyan007

我的应用程序意外关闭,但这很奇怪,因为我正处于开发的开始阶段,所以该应用程序没有什么特别的! 我的第一个类:

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 list 是正确的:

<?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 上,但这很荒谬

有人可以帮助我吗? 看到不正常了吗?

这是我的 logcat:

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 list 是正确的:

<?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 的条目放入 list 中。