私はウィジェットに取り組んでいます。これは、ユーザーのアクションによって、インテントを使用して通常の Android カレンダーを開くものです。私は現在 ICS に取り組んでいるので、古いバージョンの API にはあまり関心がありません。次のコードで日ビューを開くことができます。
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);
ただし、月表示で開く方法が見つからないようです。AllInOneActivityの GrepCode によると、そのonCreate
メソッドで呼び出しUtils.getViewTypeFromIntentAndSharedPref(this);
て、表示するビューを決定します。その方法は次のとおりです。
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);
}
ビューを MonthView に設定する方法は、このメソッド (または他の場所) にはありません。私が使用できるある種のトリックはありますか、それともこれが不可能であることを受け入れる必要がありますか?