title: Sending data from Servica to BroadcasReceiver to update progress bar
body: <p>In <code>Service</code> I have <code>CountDownTimer</code>. I want to send progress data to <code>BroadcastReceiver</code> in <code>MainActivity</code> and set progress. How to send this data and upgrade progress bar?
   MyReceiver is not called.</p>
  
  <p>MainActivity:</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      public class MyReceiver extends BroadcastReceiver
      {
          ProgressBar pBar = (ProgressBar) findViewById(R.id.progressBar);
          @Override
          public void onReceive(Context context, Intent intent) {
              int ola = intent.getIntExtra("NUMBER", 0);
              pBar.setProgress(ola);
              Log.d("dddReceiver" ,  String.valueOf(ola) );   //can't see     
          }   
      }
  ...
  }
  </code></pre>
  
  <p>Service</p>
  
  <pre><code>public void onStart(Intent intent, int startId) {
             String message = (String) intent.getStringExtra("EXTRA_MESSAGE");
             timeToWait = Integer.parseInt(message);
  
              CountDownTimer cdt = new CountDownTimer(timeToWait * 1000, 1000) {
              int i = 0;
              Intent intentBack = new Intent(getApplicationContext(),
                          MyReceiver.class);
  
              public void onTick(long millisUntilFinished) {
                  intentBack.putExtra("NUMBER", i);
                  i++;
                  sendBroadcast(intentBack);
              }
               public void onFinish() {
                  Toast.makeText(getApplicationContext(), "Finished",
                          Toast.LENGTH_SHORT).show();
                  i++;
                  Log.i("dddLongFinish", String.valueOf(i));
              }
          };
          cdt.start();
      }
  </code></pre>
  
  <p>Manifest</p>
  
  <pre><code>&lt;receiver 
     android:name="MyReceiver"  &gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>After first answer:</p>
  
  <blockquote>
    <p>11-23 14:20:23.713: W/dalvikvm(20992): threadid=1: thread exiting with
    uncaught exception (group=0x400207d8) 11-23 14:20:23.723:
    E/AndroidRuntime(20992): FATAL EXCEPTION: main 11-23 14:20:23.723:
    E/AndroidRuntime(20992): java.lang.RuntimeException: Unable to
    instantiate activity
    ComponentInfo{com.example.serwis/com.example.serwis.MainActivity}:
    java.lang.NullPointerException 11-23 14:20:23.723:
    E/AndroidRuntime(20992):  at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
    11-23 14:20:23.723: E/AndroidRuntime(20992):  at
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    11-23 14:20:23.723: E/AndroidRuntime(20992):  at
    android.app.ActivityThread.access$2300(ActivityThread.java:125) 11-23
    14:20:23.723: E/AndroidRuntime(20992):    at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    11-23 14:20:23.723: E/AndroidRuntime(20992):  at
    android.os.Handler.dispatchMessage(Handler.java:99) 11-23
    14:20:23.723: E/AndroidRuntime(20992):    at
    android.os.Looper.loop(Looper.java:123) 11-23 14:20:23.723:
    E/AndroidRuntime(20992):  at
    android.app.ActivityThread.main(ActivityThread.java:4627) 11-23
    14:20:23.723: E/AndroidRuntime(20992):    at
    java.lang.reflect.Method.invokeNative(Native Method) 11-23
    14:20:23.723: E/AndroidRuntime(20992):    at
    java.lang.reflect.Method.invoke(Method.java:521) 11-23 14:20:23.723:
    E/AndroidRuntime(20992):  at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
    11-23 14:20:23.723: E/AndroidRuntime(20992):  at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 11-23
    14:20:23.723: E/AndroidRuntime(20992):    at
    dalvik.system.NativeStart.main(Native Method) 11-23 14:20:23.723:
    E/AndroidRuntime(20992): Caused by: java.lang.NullPointerException
    11-23 14:20:23.723: E/AndroidRuntime(20992):  at
    android.app.Activity.findViewById(Activity.java:1637) 11-23
    14:20:23.723: E/AndroidRuntime(20992):    at
    com.example.serwis.MainActivity$1.(MainActivity.java:19) 11-23
    14:20:23.723: E/AndroidRuntime(20992):    at
    com.example.serwis.MainActivity.(MainActivity.java:18) 11-23
    14:20:23.723: E/AndroidRuntime(20992):    at
    java.lang.Class.newInstanceImpl(Native Method) 11-23 14:20:23.723:
    E/AndroidRuntime(20992):  at
    java.lang.Class.newInstance(Class.java:1429) 11-23 14:20:23.723:
    E/AndroidRuntime(20992):  at
    android.app.Instrumentation.newActivity(Instrumentation.java:1021)
    11-23 14:20:23.723: E/AndroidRuntime(20992):  at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
    11-23 14:20:23.723: E/AndroidRuntime(20992):  ... 11 more</p>
  </blockquote>