Friday, December 27, 2013

Start multiple Activities using Intent

This blog is related to start multiple Activity using Intent.

Generally we are using Intent for start new Activity in android.
But now you can start multiple activity using single intent.

method : startActivities(Intent[] intent)

Keep in mind that this method is used from Above API 11

See more update about android here

Use of this method

In your Activity

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Intent[] array = {};

Intent demo1  = new Intent(MainActivity.this,YOURACTIVITY.class);
Intent demo2 = new Intent(MainActivity.this,YOURACTIVITY.class);
Intent demo3  = new Intent(MainActivity.this,YOURACTIVITY.class);
Intent demo4  = new Intent(MainActivity.this,YOURACTIVITY.class);

startActivities(array);
}

}

Note that unlike that approach, generally none of the activities except the lase in the array will be created at this point, but rather will be created when the user first visits them (due to pressing back from the activity on top).

See more update about android here





No comments:

Post a Comment