how to open native calendar from titanium app for android and iOS? As in, on the click of a button, i want to open the native calendar on the ipad.
1
votes
2 Answers
1
votes
In android you can open it using a native intent, as explained here
There's a difference between versions lower and greater than Gingerbread. There's also a difference in HTC devices because of the HTC Sense Software, as explained at the end of this question.
Here is my tested code for Titanium:
if (Titanium.Platform.osname=="android"){
//Params needed to create the android intent.
var packageStr = "com.google.android.calendar";
var classStr = "com.android.calendar.LaunchActivity";
var actionStr = Ti.Android.ACTION_VIEW;
var model = Ti.Platform.model;
if ((model.indexOf("HTC") != -1) || (model.indexOf("htc") != -1)){
//If it's a HTC device
packageStr = "com.htc.calendar";
classStr = "com.htc.calendar.MonthActivity";
actionStr = Ti.Android.ACTION_MAIN;
}
else {
//For android versions before Gingerbread (2.3)
var version = parseFloat(Ti.Platform.version);
if (version < 2.4) packageStr = "com.android.calendar";
}
//Launch native calendar
var intent = Ti.Android.createIntent({
action: actionStr,
packageName: packageStr,
className: classStr
});
Ti.Android.currentActivity.startActivity(intent);
}
You can also open the "create event" screen of the native calendar by adapting this for Titanium in the same way as the code above