Hi Mike,

I mean you can register one BroadcastReceiver in A to receive the
broadcast taht is sent from B.

For example,

public class A extends Activity{

    public void onCreate(Bundle b){
    .
    .
    .
    registerFinishedReceiver();
    }

    private void registerFinishedReceiver(){
        IntentFilter filter = new
IntentFilter("idv.nightgospel.action.FINISH");
        registerReceiver(finishedReceiver, filter);
    }

    public void onDestroy(){
        super.onDestroy();
        unregisterReceiver(finishedReceiver);  // never forget to
unregister receivers
    }

    BroadcastReceiver finishedReceiver = new BroadcastReceiver(){
        public void onReceive(Context context, Intent intent){
        A.this.finish();   //  we finish Activity A here when
receiving the broadcast
        }
    };
}

public class B extends Activity{
    .
    .
    .
    public boolean onKeyDown(int keyCode, KeyEvent event) {
                // TODO Auto-generated method stub
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                        Intent intent = new
Intent("idv.nightgospel.action.FINISH");
                        sendBroadcast(intent);  //  we send broadcast
here to tell A, you should
                                                //  finish yourself
                        finish();
                        return true;
                }
                return false;
        }
}

The above sample codes are what I mean.

NightGospel

On 6月2日, 下午7時07分, mike <[email protected]> wrote:
> hi NightGospel,
>
> what exactly did u mean? could u please give me a sample?
>
> regrads,
> Randika
>
> On Jun 2, 3:48 pm, NightGospel <[email protected]> wrote:
>
>
>
> > Hi Mike,
>
> > How about sending a broadcast to A when pushing back button in B ?
>
> > NightGospel
>
> > On 6月2日, 下午5時03分, mike <[email protected]> wrote:
>
> > > hi kamiseq,
>
> > > so then how can i finish the Activity A from Activity B???
>
> > > can't use finishActivity()????
>
> > > regards,
> > > Randika

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