For passing stuff from Activity-A to Activity-B, use a bundle and pass it in
the intent while starting the target activity.
Intent intent = new Intent(ActivityA.class, ActivityB.class);
intent.putExtra("name", "myName");
intent.putExtra("age", 24);
startActivity(intent);
>From the target activity, retrieve the bundle and access the passed data.
Bundle extras = intent.getExtras();
//get your stuff from the bundle.
On Fri, Nov 20, 2009 at 4:52 AM, fala70 <[email protected]> wrote:
> I've a problem to solve about pass reference between objects Activity.
> Suppose follow situation with 3 class and 1 interface:
>
> I don't know how pass the reference of MyEvents (_engine) to ActivityB
> from ActivityA::StartActivityB()
>
> public interface MyEvents {
> public abstract void MakeThis();
> }
> public class Engine implements Runnable, MyEvents {
> void Init(){
> _th = new Thread(this);
> _th.start();
> }
> public void run() {
> ....
> }
> void MakeThis(){
> ...
> }
> }
>
> public class ActivityA extends Activty {
> Engine _engine;
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> _engine = new Engine();
> _engine.Init(); // start thread
> }
> void StartActivityB(){
> Intent intent = new Intent(ActivityA.this, ActivityB.class);
> startActivity(intent);
> }
>
> }
>
> public class ActivityB extends Activty {
> MyEvents _myEvent;
>
> ActivityB(MyEvents myEvent){
> _myEvent = myEvent;
> }
>
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> _myEvent.MakeThis();
> }
> }
>
>
> Thanks
>
> --
> 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]<android-developers%[email protected]>
> For more options, visit this group at
> http://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