我的App Force突然关闭

时间:2015-03-08 17:09:50

标签: android

我创建了一个包含10页的应用程序,花了15天时间来完成这个项目。现在我面临一个大问题。如果我锁定并解锁我的手机我的应用程序关闭。我不知道为什么会这样?

此处附上我的清单供您参考。请让我以任何方式解决我的问题。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.menu.mymenu"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/MyTheme" >
        <activity
            android:name="com.menu.pages.MenuPage"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >
        </activity>
        <activity
            android:name="com.menu.pages.OrderedItem"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >
        </activity>
        <activity
            android:name="com.menu.pages.EditPage"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >
        </activity>
        <activity
            android:name="com.menu.pages.InsertProducts"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >
        </activity>
        <activity
            android:name="com.menu.pages.HomePage"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >
        </activity>
        <activity
            android:name="com.menu.pages.SignUpPageActivity"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >

        </activity>
        <activity
            android:name="com.menu.pages.UserCreation"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >
        </activity>
        <activity
            android:name="com.menu.pages.Login_Activity"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >
        </activity>
        <activity
            android:name="com.menu.pages.SplashScreen"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >
             <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

这是我的SplashScreen:

public class SplashScreen extends Activity {

    New_SQLController sqlcon;

    @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.splash_screen_layout);
        sqlcon = new New_SQLController(this);

        if (CommonVariables.loggedIn) {
            if (getCount() > 0) {
                CommonVariables.fromMainPage = true;
                Intent homeIntent = new Intent(this, HomePage.class);
                startActivity(homeIntent);
            } else {
                Intent signUpIntent = new Intent(this, SignUpPageActivity.class);
                startActivity(signUpIntent);
            }
        } else {
            Intent signUpIntent = new Intent(this, SignUpPageActivity.class);
            startActivity(signUpIntent);
        }

        finish();
    }

    private int getCount() {
        sqlcon.open();
        int count = 0;
        count = sqlcon.getAdminCount();
        sqlcon.close();
        return count;

    }

    @Override
    protected void onPause() {
        super.onPause();

    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

    }

}

2 个答案:

答案 0 :(得分:0)

您的应用已关闭,因为finish()方法中有onCreate()方法。

删除finish()方法。

答案 1 :(得分:0)

最后我找到了解决方案..我添加了

android:configChanges="screenLayout|orientation|screenSize|smallestScreenSize|layoutDirection"

我的清单活动条目中的这一行。现在我的app工作正常。我从this link找到了解决方案。