启动第二个活动后应用程序崩溃

时间:2014-11-06 08:49:56

标签: android

我有一点问题。我有两个设备,(在第一个设备中一切正常)但在第二个设备中我有一个错误,当第二个活动开始时它会崩溃应用程序。

logcat的:

10-21 19:51:07.186: E/AndroidRuntime(2918): FATAL EXCEPTION: main
10-21 19:51:07.186: E/AndroidRuntime(2918): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.saitonashi.lolquestions/com.saitonashi.lolquestions.EndGame}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.app.ActivityThread.access$600(ActivityThread.java:138)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.os.Looper.loop(Looper.java:213)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.app.ActivityThread.main(ActivityThread.java:4787)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at java.lang.reflect.Method.invokeNative(Native Method)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at java.lang.reflect.Method.invoke(Method.java:511)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at dalvik.system.NativeStart.main(Native Method)
10-21 19:51:07.186: E/AndroidRuntime(2918): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.view.LayoutInflater.createView(LayoutInflater.java:613)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:262)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.app.Activity.setContentView(Activity.java:1867)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at com.saitonashi.lolquestions.EndGame.onCreate(EndGame.java:65)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.app.Activity.performCreate(Activity.java:5008)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
10-21 19:51:07.186: E/AndroidRuntime(2918):     ... 11 more
10-21 19:51:07.186: E/AndroidRuntime(2918): Caused by: java.lang.reflect.InvocationTargetException
10-21 19:51:07.186: E/AndroidRuntime(2918):     at java.lang.reflect.Constructor.constructNative(Native Method)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.view.LayoutInflater.createView(LayoutInflater.java:587)
10-21 19:51:07.186: E/AndroidRuntime(2918):     ... 23 more
10-21 19:51:07.186: E/AndroidRuntime(2918): Caused by: java.lang.OutOfMemoryError
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.content.res.Resources.loadDrawable(Resources.java:1935)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.view.View.<init>(View.java:3392)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.view.ViewGroup.<init>(ViewGroup.java:460)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.widget.LinearLayout.<init>(LinearLayout.java:180)
10-21 19:51:07.186: E/AndroidRuntime(2918):     at android.widget.LinearLayout.<init>(LinearLayout.java:176)
10-21 19:51:07.186: E/AndroidRuntime(2918):     ... 26 more
10-21 19:51:09.796: I/Process(2918): Sending signal. PID: 2918 SIG: 9

在Manifest文件中,我实现了所有活动。

    <activity 
        android:name="com.saitonashi.lolquestions.GameActivity"
        android:label="@string/app_name"
        android:screenOrientation="landscape" 
        android:configChanges="keyboardHidden|orientation|screenSize">
    </activity>

    <activity 
        android:name="com.saitonashi.lolquestions.EndGame"
        android:label="@string/app_name"
        android:screenOrientation="landscape" >
    </activity>

第一项活动的意图:

    if (questionsComplete >= 15) {
        bundle = new Bundle();
        bundle.putBoolean("END", true);
        iGameEnd.putExtras(bundle);

        startActivityForResult(iGameEnd, END_GAME);
    }

第二个活动XML:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/lay_noti"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="@dimen/activity_horizontal_margin"
        android:orientation="vertical"
        android:gravity="center"
        android:background="@drawable/noty_wl" >

        <Button
            android:id="@+id/lol_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="@dimen/activity_horizontal_margin"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:background="@drawable/lol_victory"
            android:text="@string/alert_win_msg"
            android:textColor="#ffffff"
            android:textSize="30sp"
            android:contentDescription="@string/alert_win_msg" />

    </LinearLayout>

和java文件:

public void GameNoty() {

    Button btn = (Button) findViewById(R.id.lol_button);
    bundle = getIntent().getExtras();
    bool = bundle.getBoolean("END");

    if (bool == true) {
        btn.setBackgroundResource(R.drawable.lol_victory);
        btn.setText(R.string.alert_win_msg);
        // Set screen name.
    } else if (bool == false) {
        btn.setBackgroundResource(R.drawable.lol_defeat);
        btn.setText(R.string.alert_lose);
        // Set screen name.
    }

    btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showDialog(DIALOG_PY);          
        }
    });
}

0 个答案:

没有答案