任何人都可以在手机启动后立即给我提供启动应用程序的示例代码
答案 0 :(得分:5)
你需要这样的BroadcastReceiver
public class MyBroadcastreceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Intent i = new Intent(YourClass)
context.startService(i);
}
}
}
也是此用户权限
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
以及manifest.xml中标记中的recever
<receiver android:name="com.example.MyBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>