如何从钛金属应用程序打开本机日历?

时间:2013-04-08 11:07:39

标签: titanium titanium-alloy

如何从适用于Android和iOS的钛应用程序打开本机日历?就像在单击按钮时,我想在ipad上打开本机日历。

2 个答案:

答案 0 :(得分:1)

只需使用:

Titanium.Platform.openURL( 'CALSHOW://');

答案 1 :(得分:1)

在Android中,您可以使用原生意图打开它,如here

所述

低于和高于Gingerbread的版本之间存在差异。 HTC Sense软件也存在差异,正如this问题末尾所解释的那样。

这是我测试的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);
    }

您也可以通过调整this for Titanium打开本机日历的“创建事件”屏幕,其方式与上面的代码相同

相关问题