title: Android App crashed after some time
body: <p>I've a problem which I do not have a clue on what causing the crash. I have a inner class of Timer which is triggered from the <code>MainActivity</code> <code>onCreate()</code> every minute.</p>
  
  <pre><code>timer = new Timer(); 
  timer.scheduleAtFixedRate(new RemindTask(),2000, 10000);
  </code></pre>
  
  <p>This is my Timer class.This timer class responsible in start another activity.</p>
  
  <pre><code>class RemindTask extends TimerTask {
  
  public CaptureActivityHandler cah = new CaptureActivityHandler();
  public void run() {
      Log.d("TIMER",  "timer is triggered");
      TimerCount++;
  
      if(TimerCount &gt; 1)
      {
          Log.d("TIMER",  "TimerCount &gt; 1");
          boolean flag = cah.getDecodeFlag();
  
          if(flag){
              Log.d("TIMER",  "decodeFlag true");
              cah.setDecodeFlag(false);
              Intent intent = new Intent(MainActivity.this,CaptureActivity.class);
              startActivityForResult(intent,SCAN_QRCODE_REQUEST);
          }
          else
          {
              Intent intent = new Intent(MainActivity.this,CaptureActivity.class);
              startActivityForResult(intent,SCAN_QRCODE_REQUEST);
          }
      }
      else {
          Intent intent = new Intent(MainActivity.this,CaptureActivity.class);
          startActivityForResult(intent,SCAN_QRCODE_REQUEST);
      }
     }
  }
  </code></pre>
  
  <p>The problem is the app crashed after 15 hours. Logcat showing:</p>
  
  <pre><code>01-21 11:01:42.027: W/dalvikvm(30401): threadid=11: thread exiting with uncaught  exception (group=0x41ddd930)
  01-21 11:01:42.027: W/ActivityManager(363): Unable to find app for caller   android.app.ApplicationThreadProxy@4275bf18 (pid=-1) when starting: Intent {  cmp=com.handalindah.manjalinkkiosk/tw.com.quickmark.sdk.CaptureActivity }
  01-21 11:01:42.027: E/AndroidRuntime(30401): FATAL EXCEPTION: Timer-0
  01-21 11:01:42.027: E/AndroidRuntime(30401): java.lang.SecurityException: Not allowed to start activity Intent { cmp=com.handalindah.manjalinkkiosk/tw.com.quickmark.sdk.CaptureActivity }
  01-21 11:01:42.027: E/AndroidRuntime(30401):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1625)
  01-21 11:01:42.027: E/AndroidRuntime(30401):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
  01-21 11:01:42.027: E/AndroidRuntime(30401):    at android.app.Activity.startActivityForResult(Activity.java:3370)
  01-21 11:01:42.027: E/AndroidRuntime(30401):    at android.app.Activity.startActivityForResult(Activity.java:3331)
  01-21 11:01:42.027: E/AndroidRuntime(30401):    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
  01-21 11:01:42.027: E/AndroidRuntime(30401):    at com.handalindah.manjalinkkiosk.MainActivity$RemindTask.run(MainActivity.java:562)
  01-21 11:01:42.027: E/AndroidRuntime(30401):    at java.util.Timer$TimerImpl.run(Timer.java:284)
  01-21 11:01:42.037: W/ActivityManager(363): Can't find mystery application for Crash from pid=30401 uid=10079: android.os.BinderProxy@42976028
  01-21 11:01:42.037: I/Process(30401): Sending signal. PID: 30401 SIG: 9
  01-21 11:01:42.147: W/InputDispatcher(363): channel '42600fd8 com.handalindah.manjalinkkiosk/com.handalindah.manjalinkkiosk.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
  01-21 11:01:42.147: E/InputDispatcher(363): channel '42600fd8 com.handalindah.manjalinkkiosk/com.handalindah.manjalinkkiosk.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
  01-21 11:01:42.147: W/InputDispatcher(363): Attempted to unregister already unregistered input channel '42600fd8 com.handalindah.manjalinkkiosk/com.handalindah.manjalinkkiosk.MainActivity (server)'
  01-21 11:01:42.147: I/WindowState(363): WIN DEATH: Window{42600fd8 u0 com.handalindah.manjalinkkiosk/com.handalindah.manjalinkkiosk.MainActivity}
  </code></pre>
  
  <p>Then having the thought it may caused by memory leak, then I shorten the timer period to 10secs. As expected, it crashed after 2.5 hours. </p>
  
  <p>However, It's seems unlikely is because of the memory because the used heap size is always about 58%. Besides, the memory usage is about 4% which is 35M out of total 100% of device memory.</p>
  
  <p>Here is the manifest.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.test"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="17" /&gt;
  
  &lt;uses-feature android:name="android.hardware.camera" /&gt;
  &lt;uses-feature android:name="android.hardware.camera.front" /&gt;
  &lt;uses-feature android:name="android.hardware.camera.autofocus" /&gt;
  
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
  &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
  &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  
  &lt;application
      android:largeHeap="true"
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:name="com.example.test.MainActivity"
          android:label="@string/app_name"
          android:launchMode="singleTop"&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="tw.com.quickmark.sdk.CaptureActivity"
          android:configChanges="orientation|keyboardHidden"
          android:screenOrientation="portrait"
          android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
          android:launchMode="singleTop"&gt;
  
      &lt;/activity&gt;
      &lt;activity android:name="tw.com.quickmark.sdk.PreferencesActivity" &gt;
      &lt;/activity&gt;
  
      &lt;service
          android:name="com.example.test.MySpiceService"
          android:exported="false" &gt;
      &lt;/service&gt;
   &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Any thought of what might cause the crashing? </p>