tags:

views:

42

answers:

3

Hello

I'm trying to create calendar for android. There is a month switcher (previous/next month). How can I call the same activity (which displays the calendar) with other parameters...

e.g. previous month will have CalendarMonth(java.util.Calendar.MONTH - 1)

and next month will have CalendarMonth(java.util.Calendar.MONTH + 1)

current month will have nothing in costructor

Hope it's clear :)

Thanks for help in advance

A: 

If I understood correctly, this is what you want:

Intent myIntent = new Intent();
myIntent.setClassName("com.peter.calendar", "com.peter.calendar.CalendarMonthActivity");
myIntent.putExtra("month", "November");
startActivity(myIntent);

Use December instead of November, and you have effectively called your activity with different parameters. In the activity, just retrieve those extras to know which month the caller wanted.

espinchi
A: 

You need to put the parameter in a bundle. and parse to the intent.

Bundle b = new Bundle;
b.put(....)
Intent intent = new Intent(this, newActivity.class);
intent.setBundle(b);
startActivity(intent)
bob
A: 

you can use the flag Intent.FLAG_ACTIVITY_CLEAR_TOP

with the android:launchMode "singleTop"

and handle your new intent in : public void onNewIntent(Intent newIntent)

GBouerat