I am working on widgets that, among other things, open a regular Android calendar using intentions for some user actions. I am currently working on ICS, so I donβt know much about older versions of the API. I can open the day view with the following code:
Intent intent2 = new Intent(); intent2.setComponent(new ComponentName("com.android.calendar", "com.android.calendar.AllInOneActivity")); intent2.setAction("android.intent.action.MAIN"); intent2.addCategory("android.intent.category.LAUNCHER"); intent2.setFlags(0x10200000); intent2.putExtra("beginTime", dateStartMillis); intent2.putExtra("VIEW", "DAY"); context.startActivit(intent2);
However, I cannot find a way to open it in month mode. According to GrepCode for AllInOneActivity, in its onCreate method onCreate it calls Utils.getViewTypeFromIntentAndSharedPref(this); to determine which view to display. Here is the method:
public static int getViewTypeFromIntentAndSharedPref(Activity activity) { Intent intent = activity.getIntent(); Bundle extras = intent.getExtras(); SharedPreferences prefs = GeneralPreferences.getSharedPreferences(activity); if (TextUtils.equals(intent.getAction(), Intent.ACTION_EDIT)) { return ViewType.EDIT; } if (extras != null) { if (extras.getBoolean(INTENT_KEY_DETAIL_VIEW, false)) { // This is the "detail" view which is either agenda or day view return prefs.getInt(GeneralPreferences.KEY_DETAILED_VIEW, GeneralPreferences.DEFAULT_DETAILED_VIEW); } else if (INTENT_VALUE_VIEW_TYPE_DAY.equals(extras.getString(INTENT_KEY_VIEW_TYPE))) { // Not sure who uses this. This logic came from LaunchActivity return ViewType.DAY; } } // Default to the last view return prefs.getInt( GeneralPreferences.KEY_START_VIEW, GeneralPreferences.DEFAULT_START_VIEW); }
I do not see in this method (or anywhere else in this case) the ability to set the view in MonthView. Is there any trick I can use, or should I just accept that this is not possible?
source share