1

I am trying to listen for status of gsm enabled (activated) on device.

I looked over Settings, but did not find something which match this (there is wifi enabled but not gsm/data enabled).

Is there any way to listen for gsm activate event ?

I have tried the following but is does not catch "data enabled" events:

ContentResolver contentResolver = context.getContentResolver();
Uri setting = Settings.System.getUriFor("mobile_data");
ContentObserver observer = new ContentObserver(new Handler()) {
    @Override
    public void onChange(boolean selfChange) {
        super.onChange(selfChange);
    }

    @Override
    public boolean deliverSelfNotifications() {
        return true;
    }
};

EDIT:

I need to see if gsm is enabled ( NOT the same as data connectivity). GSM can be enabled (by user) and at the same time there might be no connectivity (if device is far from stations for example).

Thank you, Ran

ransh
  • 1,589
  • 4
  • 30
  • 56
  • I might have a similar code for this, but I think I found the base fo it around here. I will try to find it once I get home. Might be this thread : [Network listener Android](http://stackoverflow.com/q/1783117/4391450) – AxelH Jan 24 '17 at 13:08
  • thanks!, I checked the link but it listen to data connectivity not to gsm enabled (not the same). I want to see if gsm enabled in device (bu user), for power issues. note that it can be enabled, and there might be no connectivity at the same time ! I am interested if the gsm module is active in device. – ransh Jan 24 '17 at 13:14
  • Well, you used `mobile_data` in your example, so I suggest wrong. But check [`PhoneStateListener`](https://developer.android.com/reference/android/telephony/PhoneStateListener.html). I will try this later if needed. – AxelH Jan 24 '17 at 13:23
  • thanks that we'll be helpful! – ransh Jan 24 '17 at 14:37
  • if you had a solution for this problem, you can post an answer. This could be helpful in the futur. – AxelH Apr 20 '17 at 06:58

0 Answers0