I used BroadcastReceiver to start my application on boot, but it is not starting
here is my code
Manifest code :
You are using startService()
and MainActivity
is not a Service
. You need to use startActivity()
instead.
public class MyBroadcastreceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Intent startActivityIntent = new Intent(context, MainActivity.class);
startActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(startActivityIntent);
}
}