How is it strange? You wrote code that displays a Toast when the back
key is pressed, and it does exactly that.

On Wed, May 5, 2010 at 8: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 at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Romain Guy
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

-- 
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

Reply via email to