title: App closes when pressing home button
body: <p>Whenever I presses the home button on my application then go back again, the app seems to have stopped. I really don't know why since I haven't done anything yet. So that means the only thing that was executed is my oncreate, onresume, onpause and on destroy. I'm not doing anything in onresume, onpause and destroy. No service started yet or anything just loading and initializing data in oncreate. One another thing is, it is not crashing, it just stopped or closes. No errors. I will share to you my onCreate button. Maybe you will see the reason that is causing this to happen.</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  
          setContentView(R.layout.layout_landstar_page);
  
          preferences = getSharedPreferences(pref_data, Context.MODE_PRIVATE);
          alertDialogBuilder = new AlertDialog.Builder(this);
          i = new Intent(this, BGService.class);
  
          shipmentAvailableLayout = ((LinearLayout)findViewById(R.id.shipment_available_layout));
          shipmentNotAvailableLayout = ((LinearLayout)findViewById(R.id.shipment_notavailable_layout));
          menu = ((RelativeLayout)findViewById(R.id.menu));
          declineBtn = ((Button)findViewById(R.id.declinebtn));
          acceptBtn = ((Button)findViewById(R.id.acceptbtn));
          callHelpDeskBtn = ((Button)findViewById(R.id.callhelpdeskbtn));
          menuBtn = ((ImageView)findViewById(R.id.menubtn));
          refreshBtn = ((ImageView)findViewById(R.id.refreshbtn));
          logoutBtn = ((ImageView)findViewById(R.id.logoutbtn));
          trackingMsgShipment = ((TextView)findViewById(R.id.tracking_message_shipment));
  
          powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
          wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
                  "MyWakeLock");
  
          registerReceiver(broadcastReceiver, new IntentFilter(BGService.BROADCAST_ACTION));
  
          final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
  
          ((Button)findViewById(R.id.acceptbtn)).setOnTouchListener(new View.OnTouchListener() {
  
              public boolean onTouch(View v, MotionEvent event) {
                  if(event.getAction()==MotionEvent.ACTION_DOWN)
                      acceptBtn.setBackgroundResource(R.drawable.accept_selected);
                  if(event.getAction()==MotionEvent.ACTION_UP)
                  {
                      acceptBtn.setBackgroundResource(R.drawable.accept_idle);
  
                      if(isNetworkConnected())
                      {
                          acceptLoad();
  
                      }
                      else
                          noConnection();
                  }
                  return false;
              }
          });
  
          ((Button)findViewById(R.id.declinebtn)).setOnTouchListener(new View.OnTouchListener() {
  
              public boolean onTouch(View v, MotionEvent event) {
                  if(event.getAction()==MotionEvent.ACTION_DOWN)
                      declineBtn.setBackgroundResource(R.drawable.decline_selected);
                  if(event.getAction()==MotionEvent.ACTION_UP)
                  {
                      declineBtn.setBackgroundResource(R.drawable.decline_idle);
                      declineLoad();
                  }
                  return false;
              }
          });
  
          ((Button)findViewById(R.id.callhelpdeskbtn)).setOnTouchListener(new View.OnTouchListener() {
  
              public boolean onTouch(View v, MotionEvent event) {
                  if(event.getAction()==MotionEvent.ACTION_DOWN)
                      callHelpDeskBtn.setBackgroundResource(R.drawable.btn_refresh_selected);
                  if(event.getAction()==MotionEvent.ACTION_UP)
                  {
                      callHelpDeskBtn.setBackgroundResource(R.drawable.btn_refresh_idle);
                      if(isNetworkConnected())
                      {
                          displayProgressSpinner();
                      }
                      else
                          noConnection();
                  }
                  return false;
              }
          });
  
          ((ImageView)findViewById(R.id.menubtn)).setOnTouchListener(new View.OnTouchListener() {
              public boolean onTouch(View v, MotionEvent event) {
                  if(event.getAction()==MotionEvent.ACTION_DOWN)
                  {
                      if(menu.isShown())
                      {
                          menu.setVisibility(View.GONE);
                      }
                      else
                      {
                          menu.setVisibility(View.VISIBLE);
                      }
                  }
                  return false;
              }
          });
  
          ((ImageView)findViewById(R.id.refreshbtn)).setOnTouchListener(new View.OnTouchListener() {
              public boolean onTouch(View v, MotionEvent event) {
                  if(event.getAction()==MotionEvent.ACTION_DOWN)
                  {
                      menu.setVisibility(View.GONE);
                      if(isNetworkConnected())
                          displayProgressSpinner();
                      else
                          noConnection();
                  }
                  return false;
              }
          });
  
          ((ImageView)findViewById(R.id.logoutbtn)).setOnTouchListener(new View.OnTouchListener() {
              public boolean onTouch(View v, MotionEvent event) {
                  if(event.getAction()==MotionEvent.ACTION_DOWN)
                  {
                      menu.setVisibility(View.GONE);
  
                      try{
                          checkerTimer.cancel();
                          gpsTimer.cancel();
                          counterTimer2.cancel();
                      }
                      catch (Exception e) {
                          e.printStackTrace();
                      }
                      Log.i("isAccept", preferences.getString("isAccepted",""));
  
                      alertDialogBuilder.setTitle("Message");
                      alertDialogBuilder
                      .setMessage("Clicking the log out button will stop your GPS and exit the application. Are you sure?")
                          .setCancelable(false)
                          .setNegativeButton("Logout",new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog,int id) {
  
                                  SharedPreferences.Editor editor = preferences.edit();
                                  editor.putString("isDriverLogin", "True");
                                  editor.putString("driverPassword", driverPassword);
                                  editor.putString("carrierId", carrierId);
                                  editor.putString("CCTID", cctid);
                                  editor.putString("shipment", entityShipment);
                                  editor.putString("isAccepted", "");
                                  editor.commit();
                                  getApplicationContext().stopService(i);
                                  finish();
                              }
                           })
                          .setPositiveButton("Cancel",new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog,int id) {
  
                              }
                            });
  
  
                      AlertDialog alertDialog = alertDialogBuilder.create();
                      alertDialog.show();
  
                  }
                  return false;
              }
          });
  
  
          Intent intent = getIntent();
          loadSaveDetails(intent);
      }
  </code></pre>
  
  <p>My Manifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;uses-sdk
      android:minSdkVersion="9"
      android:targetSdkVersion="17" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" 
      &gt;
      &lt;activity
          android:name="com.nesv.landstar.SplashScreen"
          android:label="@string/app_name" 
          android:screenOrientation="portrait"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;activity
          android:name="com.nesv.landstar.Login"
          android:label="@string/app_name" 
           android:screenOrientation="portrait"&gt;
      &lt;/activity&gt;
  
      &lt;activity
          android:name="com.nesv.landstar.DriverLogin"
          android:label="@string/app_name" 
           android:screenOrientation="portrait"&gt;
      &lt;/activity&gt;
  
      &lt;activity
          android:name="com.nesv.landstar.LandstarPage"
          android:label="@string/app_name" 
           android:screenOrientation="portrait"&gt;
      &lt;/activity&gt;
  
      &lt;service android:name="com.nesv.landstar.BGService"&gt;&lt;/service&gt;
  
  &lt;/application&gt;
  
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
   &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>One thing, this does not happen on a rooted samsung s3 and normal samsung s4. Tried it on S duos version 4.0 and lower up to gingerbread. And this happened.</p>
  
  <p>Another question. I tried installing it from the eclipse. This didn't happen. This only happen when I try to install the apk file that came from the bin folder on my device.</p>