Results 1 to 1 of 1
  1. #1
    Join Date
    Sep 2013
    Varazze, Italy

    Samsung SII

    Debug broadcast listener

    I implemented a dynamic broadcast listener as an inner class of a main activity but it does not intercept intents. I tried with a static listener with the same intent filter, and it intercepts the same intent. Without going into details, what is the best way to debug listeners? I'm sure that the listener is registered as I put a breakpoint on the registerListener(...) function. If the question is too vague I'll post my code when I'll be in front of my PC.

    This is the code I'm debugging.
    In order to avoid priority issues, I implemented a two step receiver.
    A first static receiver for the connectivity change that fires a new custom defined intent, that should be detected by the networkChangeReceiver.


    public class MainActivity extends Activity {
    protected void onCreate(Bundle savedInstanceState) {


    <Other stuff>

    private void addNetworkChangeReceiver() {
    IntentFilter filter = new IntentFilter();
    filter.addAction(" NGE");

    networkChangeReceiver = new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {

    // check data connection
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = cm.getActiveNetworkInfo();

    // if data connection is now available, get info from Internet
    if (netInfo != null)
    if (netInfo.isConnected()) {

    <Do other stuff>

    registerReceiver(networkChangeReceiver, filter);


    This is the static broadcast receiver (it works).

    public class NetworkReceiver extends BroadcastReceiver {

    public void onReceive(Context context, Intent intent) {
    context.sendBroadcast(new Intent(

    Last edited by sthor69; 09-24-2013 at 09:00 AM. Reason: add code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts