Как начать работу после загрузки, которая запускает функцию onCreate()
на mainActivity
? я уже использую broadcastRecivier
, я могу сделать службу, но я не могу выполнить funtion из основного действия.Начальная служба после загрузки
это мой код broadcastReciver
public class BootStartUpReciver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
//Start service on Boot
if(intent.getAction().equals(intent.getAction())){
Intent service = new Intent(context,TestService.class);
service.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(service);
}
//Start App on Boot Start up
if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
//if(intent.getAction().equals(intent.getAction())){
Intent app = new Intent(context,TestService.class);
app.setClass(context,SatuActivity.class);
app.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(app);
}
}
}
Попробуйте https: // StackOverflow .com/questions/2784441/try-to-start-a-service-on-boot-on-android? answertab = active # tab-top –