Android examples for Activity:Activity Start
Launch an Activity.
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.Window; import android.view.WindowManager; import java.util.Map; import java.util.Map.Entry; public class Main{ /**//from w w w . j a va 2 s . c om * Launch an Activity. * * @param context The current Context or Activity that this method is called from. * @param activity The new Activity to open. * @param closeCurrentActivity whether or not the current activity should close. * @param params Parameters to add to the intent as a Bundle. */ public static void launchActivity(Activity context, Class<? extends Activity> activity, boolean closeCurrentActivity, Map<String, String> params) { Intent intent = new Intent(context, activity); if (params != null) { Bundle bundle = new Bundle(); for (Entry<String, String> param : params.entrySet()) { bundle.putString(param.getKey(), param.getValue()); } intent.putExtras(bundle); } context.startActivity(intent); if (closeCurrentActivity) { context.finish(); } } /** * @see com.percolate.caffeine.ActivityUtils#launchActivity(android.app.Activity, Class, boolean, java.util.Map) */ public static void launchActivity(Activity context, Class<? extends Activity> activity, boolean closeCurrentActivity) { launchActivity(context, activity, closeCurrentActivity, null); } }