Titanium 如何从Tianium应用程序打开本机日历?
如何从适用于android和iOS的Tianium应用程序打开本机日历?如中所示,只要点击一个按钮,我就想在ipad上打开本机日历 只需使用:Titanium 如何从Tianium应用程序打开本机日历?,titanium,titanium-alloy,Titanium,Titanium Alloy,如何从适用于android和iOS的Tianium应用程序打开本机日历?如中所示,只要点击一个按钮,我就想在ipad上打开本机日历 只需使用: Titanium.Platform.openURL('CALSHOW://'); 如前所述,在android中,您可以使用本机意图打开它 比姜饼低的版本和比姜饼高的版本有区别。正如问题末尾所解释的,由于HTC Sense软件,HTC设备也存在差异 以下是我测试的钛代码: if (Titanium.Platform.osname=="androi
Titanium.Platform.openURL('CALSHOW://');
如前所述,在android中,您可以使用本机意图打开它 比姜饼低的版本和比姜饼高的版本有区别。正如问题末尾所解释的,由于HTC Sense软件,HTC设备也存在差异 以下是我测试的钛代码:
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);
}
if(Titanium.Platform.osname==“android”){
//创建android意图所需的参数。
var packagester=“com.google.android.calendar”;
var classStr=“com.android.calendar.LaunchActivity”;
var actionStr=Ti.Android.ACTION\u视图;
var模型=Ti.Platform.model;
if((model.indexOf(“HTC”)!=-1)| |(model.indexOf(“HTC”)!=-1)){
//如果是HTC设备
Packagester=“com.htc.calendar”;
classStr=“com.htc.calendar.MonthActivity”;
actionStr=Ti.Android.ACTION\u MAIN;
}
否则{
//姜饼(2.3)之前的android版本
var version=parseFloat(Ti.Platform.version);
如果(版本<2.4)Packagester=“com.android.calendar”;
}
//启动本机日历
var intent=Ti.Android.createIntent({
行动:行动,
packageName:packagester,
类名:classStr
});
Ti.Android.currentActivity.startActivity(意图);
}
您还可以通过与上面代码相同的方式调整Tianium来打开本机日历的“创建事件”屏幕,为什么?你想做什么?只需打开应用程序?是的,我有一个名为“查看日历中的约会”的按钮。单击该按钮,本机日历将打开,这仅适用于iOS。关于答案的android部分,请参见asanlo的答案。关于iOS的答案,请参见Stef的答案。