how can i call activity class from other java clas

2020-03-31 06:18发布

问题:

I have just started android.

I just want to know that how can i call activity class from other java class.

i just want to pass class object to activity class.

anyhelp please.

public class GsonParser extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    MagazineThread thread=new MagazineThread();
    thread.start();
}
public GsonParser(JsonMagazineParser Obj)
{

}

}

and i am just doing like from other class. GsonParser obj=new GsonParser(this);passing obj to activity class.how can i achieve that.

can u please tell me.

回答1:

Have a look at the documentation: http://developer.android.com/reference/android/app/Activity.html

specifically startActivity and startActivityForResult



回答2:

import android.content.Context;
import android.content.Intent;

public class Genfunctions {
    public void menuActions(String title,Context ct){

        //this.context=context;
        switch (title){
            case "ENTRIES":

                Intent intent = new Intent(ct, RptentrylistActivity.class);
                ct.startActivity(intent);
                break;
        }
    }//end of functions
}