手机启动时是否可以启动Android应用程序活动?

我试图建立一个Android应用程序,这个应用程序的关键function之一是它能够在手机启动时自动启动一个活动,我看到手机上的一些应用程序已经这样做了,任何帮助都会很棒所以我可以通过sdk更好地研究这一点,谢谢!

您需要像这样实现BroadCastreceiver:

public class PhoneStateReceiver extends BroadcastReceiver{ @Override public void onReceive(final Context context, Intent intent) { if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){ Intent launch = new Intent(context, AcitivityToLaunch.class); launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(launch); } } } 

在你的清单中添加:

      

添加权限: