I see a lot of examples of onRecieve() and BroadcastIntent etc. Still not sure how to do it. The Toast example below still does not work. I have an app with 2 activities. I would like to start the main activity on system start. So when the phone is unlocked my app will be running.
public class MainActivity extends AppCompatActivity {
Intent intent;
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Intent Detected.", Toast.LENGTH_LONG).show();
//onCreate(savedInstanceState);
}
}
}
<receiver android:name=".MainActivity$MyReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED">
</action>
</intent-filter>
</receiver>
The examples I see is with Toast and not with how to have that same app started.