i want check internet connection through out run time of android application. tried using services seems not best option. there possible way me implement broadcast receiver in service? or have give service , use broadcast receivers alone? suggestions welcome
thanks
i show how create sms receiver in service:
public class myservice extends service { @override public void oncreate() { bwllog.begin(tag); super.oncreate(); smsreceiver msmsreceiver = new smsreceiver(); intentfilter filter = new intentfilter(); filter.setpriority(intentfilter.system_high_priority); filter.addaction(sms_receive_action); // sms filter.addaction(wap_push_received_action); // mms this.registerreceiver(msmsreceiver, filter); } @override public int onstartcommand(intent intent, int flags, int startid) { super.onstartcommand(intent, flags, startid); return start_sticky; } /** * class used monitor sms */ class smsreceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { if (textutils.equals(intent.getaction(), sms_receive_action)) { //handle sms receive } } }
Comments
Post a Comment