title: Tigger alertBox from c2dm listener events
body: <p>I want to add progress and alert dialogs to whatever the active context may be, whenever the listener receives a message. With this code:</p>
  
  <pre><code>public class C2DMMessageReceiver extends BroadcastReceiver {
          @Override
                  public void onReceive(Context context, Intent intent) {
                      String action = intent.getAction();
                      Log.w("C2DM", "Message Receiver called");
                      if ("com.google.android.c2dm.intent.RECEIVE".equals(action)) {
                          Log.w("C2DM", "Received message");
                          final String payload = intent.getStringExtra("payload");
                          Log.d("C2DM", "dmControl: payload = " + payload);
  
                          // Message handling
                          if(payload.equals("DataUpdate")) {
                              progressDialog = ProgressDialog.show(context, "Please wait...", "Synchronizing data ...", true);
                  syncData(context);
                  progressDialog.dismiss();
                  AlertDialog.Builder alertbox = new AlertDialog.Builder(context);
                  alertbox.setMessage("Data was updated");
                  alertbox.create();
                  alertbox.show();
                          }
                      }
                  }
      }
  </code></pre>
  
  <p>I get the following error when i recieve message:</p>
  
  <pre><code>01-07 08:44:38.190: E/AndroidRuntime(750): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
  </code></pre>
  
  <p>Trying to figure out what the best way to handle this would be, do I need to cache the active context in a singleton, and then access said singleton from the listener? Or is there a better way? </p>
  
  <p>Thanks</p>