Android app needs to be auto-restart after the phone power On
<p>I need my app to be started automatically once after the phone reboot and Power-on. </p>

<p>I used the code provided at <a href="http://www.androidsnippets.com/autostart-an-application-at-bootup" rel="nofollow">AutoStart an Application at boot up</a> and now my android app starts automatically after the phone reboot (restart).</p>

<p>Now, consider that instead of doing a phone reboot, I have used <strong>Phone power off (Shut phone down)</strong> option. After the phone power on, my app is not started automatically as expected. Can you please explain what I have missed. </p>

<pre><code>&lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;

&lt;receiver android:enabled="true" android:name=".BootUpReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED" &gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
                &lt;category android:name="android.intent.category.DEFAULT" /&gt;
            &lt;/intent-filter&gt;
        &lt;/receiver&gt;



public class BootUpReceiver extends BroadcastReceiver
{
    private static SharedPreferences aSharedSettings;

    @Override
    public void onReceive(Context context, Intent intent) 
    {
        aSharedSettings = context.getSharedPreferences("MYPreferences", Context.MODE_PRIVATE);
        boolean isUserLoggedIn = aSharedSettings.getBoolean(kEY.AUTHENTICATED, false); 
        if(isUserLoggedIn) 
        {
Intent aServiceIntent = new Intent(context, HomeView.class);
                aServiceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(aServiceIntent); 
}

    }
}
</code></pre>

<p>Thank You.</p>
