Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
323 views
in Technique[技术] by (71.8m points)

android - Starting Service from BroadcastReceiver

I have a Service and BroadcastReceiver in my application, but how do I launch the service directly from the BroadcastReceiver? Using

startService(new Intent(this, MyService.class));

does not work in a BroadcastReceiver, any ideas?

EDIT:

context.startService(..);

works, I forgot the context part

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Don't forget

context.startService(..);


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...