android - Can a service receive its own broadcasts? -
if had service called myservice , looked this, service's broadcastreceiver recieve own broadcast "senddata" method ??
what asking is there going problem if used same intentfilter constants.service of broadcast receiver intent action send broadcasts activity ?
myservice.java
public class playerservice extends service { private ffmpegmediaplayer mp; private broadcastreceiver receiver; @override public void oncreate() { super.oncreate(); ... registerreceiver(receiver, new intentfilter(constants.service)); ... } ... public void senddata() { intent intent = new intent(constants.service); sendbroadcast(intent); } }
as adil soomro , rupesh jain mentioned apparently won't problem service cannot receive it's own broadcasts.
edit
actually after experimenting found service can receive own broadcasts if broadcastreceiver had same intentfilter broadcast intent.
Comments
Post a Comment