hi all,
This is my code.
public class MyThreadActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button) findViewById(R.id.btn1);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Log.d("MyThreadActivity", "MyThreadActivity");
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("show.me");
registerReceiver(receiver, intentFilter);
}
});
}
/**
*
*/
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Dialog dialog = new Dialog(MyThreadActivity.this);
dialog.setTitle("showme");
dialog.show();
}
};
}
//// Why the BroadcastReceiver can not start when I click button ?
How to start the BroadcastReceiver ? the registerReceiver method
was not work .
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---