Read this on the blog of developer.android.com: http://android-developers.blogspot.com/2009/12/back-and-other-hard-keys-three-stories.html
It'll tell you how to custom-handle back-key presses (and such) on 1.6 and have them compatible with 1.5 and earlier as well. On May 5, 11:48 am, inbrain <[email protected]> wrote: > I found behavior which I can not understand related to event handling. > I have task one with activity A on top of it: > > public class A extends Activity { > private static final String MMS_PACKAGE = "com.android.mms"; > private static final String SMS_INTENT_EXTRA_NAME = "sms_body"; > private static final String SMS_INTENT_TYPE = "vnd.android-dir/mms- > sms"; > > @Override > protected void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > Button checkSmsBtn = (Button)findViewById(R.id.sms_start_btn); > > checkSmsBtn.setOnClickListener(new OnClickListener() { > > public void onClick(View v) { > startActivity(createSmsIntent()); > } > }); > } > > private Intent createSmsIntent() { > String normalizedQuery = ""; > > Intent intent = new Intent(Intent.ACTION_VIEW); > intent.setComponent(new ComponentName(MMS_PACKAGE, > "com.android.mms.ui.ComposeMessageActivity")); > intent.putExtra(SMS_INTENT_EXTRA_NAME, normalizedQuery); > intent.setType(SMS_INTENT_TYPE); > > return intent; > > } > > @Override > public boolean onKeyUp(int keyCode, KeyEvent event) { > if(keyCode == KeyEvent.KEYCODE_BACK) { > Context context = getApplicationContext(); > CharSequence text = "Back button triggered"; > int duration = Toast.LENGTH_SHORT; > > Toast toast = Toast.makeText(context, text, duration); > toast.show(); > } > return super.onKeyUp(keyCode, event); > } > > } > > I have listener on my button creating intent for showing compose > message window (and passing empty message to it). Then if I press back > button (on emulator) ComposeMessageActivity will be close AND Toast in > activity A will trigger which seems very strange to me. Can anybody > explain what's going on? > > -- > 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 > athttp://groups.google.com/group/android-developers?hl=en -- 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

