title: how can i set data to text view in the broadcast receiver's onreceive method
body: <p>i want to use text view set text method in the broacast receiver class but it is not initializing text view object from the main activity.</p>
  
  <p>Main Activity</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
   TextView t1;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      t1=(TextView)findViewById(R.id.textView);
  }}
  </code></pre>
  
  <p>Broadcast receiver where i want to set data in textview which is received through broadcast intent. Toast is working fine </p>
  
  <pre><code>public class MyReceiver extends BroadcastReceiver {
  public MyReceiver() {
  }
  
  @Override
  public void onReceive(Context context, Intent intent) {
      // TODO: This method is called when the BroadcastReceiver is receiving
      // an Intent broadcast.
      String action=intent.getAction();
      String data=intent.getExtras().getString("msg");
      Toast.makeText(context,"Detected: "+action +": "+data,Toast.LENGTH_SHORT).show();
  
  }}
  </code></pre>