title: AutoStart Application not working properly
body: <p>I am having a Simple <code>AutoStart</code> Application with <code>TimerTask</code> implementation, that works fine in almost many devices. The problem is that it is not working in <code>Samsung Galaxy Y(2.3.6)</code> and <code>DELL XCD35(2.2)</code>. When the device boots <code>TimerTask</code> works for some seconds and then shuts down. I check in the <code>Application-&gt;Manage Application</code>, I saw that the Applcation was already in <code>Force Stop</code> State. That means some how my Application gets stopped after some seconds. So, what is the reason for this <code>weird behaviour</code> in these two devices, if anyone has the solution do share it.</p>
  
  <p>Below is my code.</p>
  
  <p><strong>MyReceiver.java</strong></p>
  
  <pre><code>public class MyReceiver extends BroadcastReceiver{
  
      private Timer mTimer = new Timer();
      @Override
      public void onReceive(Context context, Intent arg1) {
          Toast.makeText(context, "Device Booted", Toast.LENGTH_LONG).show();
          Log.d("TAG","Device Booted");
          mTimer.scheduleAtFixedRate(new MyTimerTask(), 2000,2000);
      }
  
      private class MyTimerTask extends TimerTask
      {
          @Override
          public void run() {
              Log.d("TAG","TimerTask executed....");
          }
      }
  }
  </code></pre>
  
  <p><strong>AndroidManifest.xml</strong></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.autostart.app"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk android:minSdkVersion="8" /&gt;
      &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/&gt;
  
      &lt;application
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name" &gt;
          &lt;receiver android:name=".MyReceiver"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.BOOT_COMPLETED"/&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>