public class TestActivity extends Activity {
/** Called when the activity is first created. */
private Button sendButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.testreceiver);
sendButton = (Button)findViewById(R.id.sendButton);
sendButton.setOnClickListener(new BroadcastListener());
}
class BroadcastListener implements OnClickListener{
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_EDIT);
TestActivity.this.sendBroadcast(intent);
}
}
}
public class TestReceiver extends BroadcastReceiver{
public TestReceiver(){
System.out.println("TestReceiver");
}
@Override
public void onReceive(Context context, Intent intent) {
System.out.println("onReceive");
}
}
public class TestBC2Activity extends Activity {
/** Called when the activity is first created. */
private Button registerButton = null;
private Button unregisterButton = null;
private SMSReceiver smsReceiver = null;