2015-03-08 85 views
0

我有一個應用程序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

回答

0

最後我找到了解決辦法。我在我的清單活動條目添加

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

0

您的應用程序正在關閉,因爲你必須在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

相關問題