我的应用程序部队突然关闭

问题描述:

我有一个应用程序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> 

这是我的闪屏:

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(); 

    } 

} 
+1

你的意思是应用程序关闭或崩溃?你可以分享堆栈跟踪以及发生这种事情吗?如果你已经实施了这些活动,请分享'onStop'和'onPause'和'onDestroy'函数吗? – 2015-03-08 17:11:57

+0

请发布堆栈跟踪。没有看到代码,这是不可能的,但是你没有正确编码'onCreate()'和'onPause/onStop()'。 – Simon 2015-03-08 17:12:20

+0

嗨..我无法连接我的手机与我的系统。所以我看不到堆栈跟踪。我的应用程序崩溃。在所有活动都会发生。 – Vijay 2015-03-08 17:18:00

最后我找到了解决办法。我在我的清单活动条目添加

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

这条线。现在我的应用工作正常。我从this link找到了解决方案。

+0

将您的答案标记为已接受,然后 – 2015-03-10 06:15:25

+1

Sure @kunal ..但是,我收到来自堆栈溢出的错误消息。 ***你可以在10小时内接受你自己的答案***。所以我会在10个小时后回答。 – Vijay 2015-03-10 06:20:22

您的应用程序正在关闭,因为你必须在onCreate()方法finish()方法。

删除finish()方法。

+0

嗨@ Fahim ..谢谢你的回复..我有一个疑问。比我怎样才能完成这项活动?我想在导航后完成此活动。 – Vijay 2015-03-08 17:41:16

+0

哦,是的,那么你将需要这条线。我们可以帮助你,如果你可以从logcat – Fahim 2015-03-08 17:45:04

+0

得到堆栈跟踪我删除了所有页面中的finish()方法。现在我仍然面临这个错误..我会尽力与我的朋友移动。可能会连接到我的系统。 – Vijay 2015-03-09 04:21:47