import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class StartupReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals( Intent.ACTION_BOOT_COMPLETED )) { Intent mainIntent = new Intent(context, main.class); mainIntent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); context.startActivity(mainIntent); } } }
<receiver android:name=".StartupReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver>