Android updating activity using LocalBroadcastManager
<p>I am using LocalBroadcastManager to update activity. I am checking for new messages from service and want to update the UI immediately if user is looking at the message activity. If he is in other activity I don't want to jump screen and get to that activity where user can see new message.</p>

<p>My following code is jumping to message activity. </p>

<p>in Service</p>

<pre><code>@Override 
public void onCreate() {
    super.onCreate();
    broadcaster = LocalBroadcastManager.getInstance(this);
}  
if (newmessage())
{ 
    Intent i = new Intent(this, MainTabHost.class);
    i.putExtra("EmpID",  userid);
    i.putExtra("type", "task");
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(i);
    broadcaster.sendBroadcast(i);
}
</code></pre>

<p>in activity</p>

<pre><code> receiver = new BroadcastReceiver() {
       @Override
       public void onReceive(Context context, Intent intent) {
           Log.w("TaskLoad", "Received the broadcast " + getCurrentTab()); 
           if(getCurrentTab().equals("0"))
            {
                   Intent i = new Intent(intent);
                   i.putExtra("EmpID", empid);
                   i.putExtra("type", "task");
                   startActivity(i); 
            }
       }
   };
</code></pre>

<p>If I comment out "i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);" in service
It says...</p>

<pre><code>android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
</code></pre>

<p>HELP ....</p>
