Android How to - Go to Activity








Question

We would like to know how to go to Activity.

Answer

/*  ww w  . jav  a 2 s . c  o  m*/
import java.util.List;

import org.apache.http.NameValuePair;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
public class Main{

    public static void goToActivity(Context currentActivity,Class<? extends Activity> newClass,List<NameValuePair> extras ) {
        Intent newActivity = new Intent(currentActivity, newClass);

        if(extras != null){
            NameValuePair thisExtra = null;
            for(int x=0;x<extras.size();x++){
                thisExtra = extras.get(x);
                newActivity.putExtra(thisExtra.getName(),thisExtra.getValue());
            }
        }

        currentActivity.startActivity(newActivity);
    }
}