public class StartBroad extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent intent1=new Intent(context,MainActivity.class);
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent1);
Toast.makeText(context,"开启APP",Toast.LENGTH_SHORT).show();
}
}
<receiver android:name=".StartBroad">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.ACTION_BOOT_IPO"/>
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
网友评论