-2

please how can I call intent From another Activity !!

public class IwannaStartIntent extends Activity{
private Context context;
.
.
public void startNewAcivity(){
Intent intent = new Intent(context,MainActivity.class);
context.startActivity(intent);
}
boubakeur
  • 1
  • 1

1 Answers1

0

I'd suggest having a helper class with factory methods like this:

          public static final String FIRST_NAME = "first_name";

          public static Intent getNameIntent(Context ctx, String firstName) {
          Intent intent = new Intent(ctx, NameActivity.class);
          intent.putExtra(FIRST_NAME, firstName);
          return intent;
          }

and then from an Activity:

             Intent intent = getNameIntent(this, "alex");
             startActivity(intent);
             // or
             startActivityForResult(intent, 1024);