Broadcast Send/Receive between Activities
<p>New to Android and trying to implement Broadcast communication between two Activities.  I've looked at many examples in books, web sites, and have followed several threads here, but I am still missing something.  Most samples have an Activity which extends from BroadcastActivity, which I believe this NOT what is needed for my app.  I put together a straight forward sample to test.</p>

<p>What am I missing?? The entire code is below.</p>

<p>Thanks for your help.</p>

<pre><code>package com.dialogtest.dt;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class DialogActivity extends Activity {

        public static final String DTAG = "ADebug";

        public static String strDia = "declr";

        public static String BroadMess = "com.dialogtest.dt.Restart";
        public static TextView tv;
    }

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


public class MainActivity extends DialogActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        
        setContentView(R.layout.main);

        strDia = "One";

        tv = (TextView) findViewById(R.id.TextView_Main);
        final Button diaButton = (Button) findViewById(R.id.Button_A);

        diaButton.setOnClickListener(new View.OnClickListener() {           
           @Override
           public void onClick(View v) {

              startActivity(new Intent(MainActivity.this, TestActivity.class));                                 
        }   
     });                                    
    }

    BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {         
            tv.setText("SUCCESS - RECEIVED!");
            Log.e(DTAG, "in Main - RECEIVED BROADCAST - str: " + strDia);
        }
    };

    @Override
    protected void onResume() {
        IntentFilter filter = new IntentFilter();
        filter.addAction(BroadMess);
        registerReceiver(receiver, filter);

        super.onResume();
    }

    @Override
    protected void onPause() {
        unregisterReceiver(receiver);

        super.onPause();
    }        
}

public class TestActivity extends DialogActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        
        setContentView(R.layout.two_dialog);

       final Button dB = (Button) findViewById(R.id.ButtonDone);       
       dB.setOnClickListener(new View.OnClickListener() {           
       @Override
       public void onClick(View v) {
           finish();
       }    
     });     
    }

    @Override
    public void onStart() {
        super.onStart();

        EditText dET = (EditText) findViewById(R.id.EditText01);       
        dET.setText(strDia);
    }

    @Override
    public void onPause() {
        super.onPause();

        EditText dET = (EditText) findViewById(R.id.EditText01);
        strDia = dET.getText().toString();

        Intent broadcast = new Intent();
        broadcast.setAction(BroadMess);
        sendBroadcast(broadcast);

        Log.e(DTAG, "in Test onPause Sending Broadcast - strDia: " + strDia);
    }

}

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.dialogtest.dt"
      android:versionCode="1"
      android:versionName="1.0"&gt;
    &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
        &lt;activity android:label="@string/app_name" android:name="MainActivity"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

    &lt;activity android:name="DialogActivity"&gt;&lt;/activity&gt;
&lt;activity android:name="TestActivity" android:theme="@android:style/Theme.Dialog"&gt;&lt;/activity&gt;
&lt;/application&gt;
    &lt;uses-sdk android:minSdkVersion="3" /&gt;
&lt;/manifest&gt;
</code></pre>
