Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5930] Android: Add the ability to create Calendars (Ti.Android.Calendar.createCalendar)

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2017-06-07T23:39:27.000+0000
Affected Version/sRelease 1.7.2, Release 1.7.3, Release 1.8.0
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, calendar
ReporterEduardo Gomez
AssigneeIngo Muschenetz
Created2011-10-31T14:26:03.000+0000
Updated2017-06-07T23:39:27.000+0000

Description

Problem

Titanium.Android.Calendar.createCalendar function not found and Ti.Android.Calendar.getCalendarById(); it doesn't work.

Titanium API method

http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Android.Calendar.createCalendar-method.html

Tested on

LG Ally Android v2.2.1 & Android Emulator v2.1, v2.2, v2.3

Repro sequence

function showCalendars(calendars) {
	var cals;
    for (var i = 0; i < calendars.length; i++) {
        cals += calendars[i].name;
    }
    return cals;
}

var calendar = Titanium.Android.Calendar.createCalendar({
	hidden : false,
	id : 1,
	name : "My calendar",
	selected : true
});

var calendar = Titanium.Android.Calendar.getCalendarById(1);

var details = { 
	 title: 'titulo',
    description: 'descrip',
    begin: 'eventBegins'
};

var evento = calendar.createEvent(details);

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');

// create tab group
var tabGroup = Titanium.UI.createTabGroup();

//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff',
    url:'test1.js'
});
var tab1 = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Tab 1',
    window:win1
});

var label1 = Titanium.UI.createLabel({
	color:'#999',
	text: showCalendars(Ti.Android.Calendar.allCalendars),
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win1.add(label1);

//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({  
    title:'Tab 2',
    backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({  
    icon:'KS_nav_ui.png',
    title:'Tab 2',
    window:win2
});

var label2 = Titanium.UI.createLabel({
	color:'#999',
	text:showCalendars(Ti.Android.Calendar.selectableCalendars),
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win2.add(label2);

//
//  add tabs
//
tabGroup.addTab(tab1);  
tabGroup.addTab(tab2);  


// open tab group
tabGroup.open();

Console log

{noformat} D/installd( 35): DexInv: --- END '/data/app/com.appcelerator.calendar-2.apk' (success) --- W/PackageManager( 60): Code path for pkg : com.appcelerator.calendar changing from /data/app/com.appcelerator.calendar-1.apk to /data/app/com.appcelerator.calendar-2.apk W/PackageManager( 60): Resource path for pkg : com.appcelerator.calendar changing from /data/app/com.appcelerator.calendar-1.apk to /data/app/com.appcelerator.calendar-2.apk D/PackageManager( 60): Services: org.appcelerator.titanium.analytics.TiAnalyticsService D/PackageManager( 60): Activities: com.appcelerator.calendar.T12218Activity org.appcelerator.titanium.TiActivity org.appcelerator.titanium.TiTranslucentActivity org.appcelerator.titanium.TiModalActivity ti.modules.titanium.ui.TiTabActivity ti.modules.titanium.ui.android.TiPreferencesActivity I/ActivityManager( 60): Force stopping package com.appcelerator.calendar uid=10044 I/installd( 35): move /data/dalvik-cache/data@app@com.appcelerator.calendar-2.apk@classes.dex -> /data/dalvik-cache/data@app@com.appcelerator.calendar-2.apk@classes.dex D/PackageManager( 60): New package installed in /data/app/com.appcelerator.calendar-2.apk I/installd( 35): free_cache(13421770) avail 7901184 W/PackageManager( 60): Couldn't clear application caches I/ActivityManager( 60): Force stopping package com.appcelerator.calendar uid=10044 I/DeviceStorageMonitorService( 60): Running low on memory. Sending notification D/dalvikvm( 118): GC_EXPLICIT freed 207 objects / 9112 bytes in 86ms I/DropBoxManagerService( 60): Usage (14) > Quota (0) D/GoogleLoginService( 169): onBind: Intent { act=android.accounts.AccountAuthenticator cmp=com.google.android.gsf/.loginservice.GoogleLoginService } D/dalvikvm( 60): GC_FOR_MALLOC freed 13318 objects / 737776 bytes in 171ms W/GoogleLoginService( 169): Device has no accounts: sending Intent { act=com.google.android.gsf.LOGIN_ACCOUNTS_MISSING } I/ActivityManager( 60): Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=318 uid=10010 gids={} D/dalvikvm( 60): GC_EXPLICIT freed 596 objects / 32696 bytes in 150ms I/installd( 35): unlink /data/dalvik-cache/data@app@com.appcelerator.calendar-1.apk@classes.dex D/AndroidRuntime( 301): Shutting down VM D/jdwp ( 301): adbd disconnected I/AndroidRuntime( 301): NOTE: attach of thread 'Binder Thread #3' failed W/RecognitionManagerService( 60): no available voice recognition services found I/ActivityThread( 318): Publishing provider com.svox.pico.providers.SettingsProvider: com.svox.pico.providers.SettingsProvider I/ActivityManager( 60): Start proc com.google.android.apps.maps:FriendService for broadcast com.google.android.apps.maps/com.google.googlenav.friend.android.ServiceReceiver: pid=329 uid=10017 gids={3003, 1015} D/AndroidRuntime( 328): D/AndroidRuntime( 328): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<< D/AndroidRuntime( 328): CheckJNI is ON D/GTalkService( 169): [GTalkService.18] account missing D/AndroidRuntime( 328): --- registering native functions --- I/ActivityManager( 60): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.appcelerator.calendar/.T12218Activity } D/AndroidRuntime( 328): Shutting down VM D/jdwp ( 328): adbd disconnected I/ActivityManager( 60): Start proc com.appcelerator.calendar for activity com.appcelerator.calendar/.T12218Activity: pid=341 uid=10044 gids={1015, 3003} I/dalvikvm( 328): JNI: AttachCurrentThread (from ???.???) I/AndroidRuntime( 328): NOTE: attach of thread 'Binder Thread #3' failed I/TiApplication( 341): (main) [0,0] checkpoint, app created. I/TiApplication( 341): (main) [286,286] Titanium 1.8.0 (2011/10/21 18:30 e69cc8f) D/TiDeployData( 341): (main) [318,604] Read deploy data: {"debuggerPort":-1,"debuggerEnabled":false,"fastdevPort":56630} I/TiRootActivity( 341): (main) [0,0] checkpoint, on root activity create, savedInstanceState: null D/dalvikvm( 341): GC_FOR_MALLOC freed 3585 objects / 342192 bytes in 65ms E/TiApplication( 341): (main) [516,516] APP PROXY: [Ti.App] D/TiCommonContactsApi( 341): (main) [21,537] Using newer contacts api. Android SDK level: 8 D/dalvikvm( 341): GC_FOR_MALLOC freed 5824 objects / 394920 bytes in 64ms I/global ( 341): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required. D/TiFastDev( 341): (kroll$1: app://app.js) [552,1089] Enabling Fastdev on port 56630 D/TiFastDev( 341): (kroll$1: app://app.js) [118,1207] sent tokens successfully D/TiFastDev( 341): (kroll$1: app://app.js) [1,1208] Fastdev session handshake succesful. D/KrollContext( 341): (kroll$1: app://app.js) [89,1297] Running evaluated script: file:///android_asset/Resources/app.js D/dalvikvm( 341): GC_FOR_MALLOC freed 7336 objects / 492600 bytes in 73ms I/ActivityManager( 60): Process android.process.acore (pid 161) has died. E/KrollContext( 341): (kroll$1: app://app.js) [311,1608] ECMA Error evaluating source: TypeError: Cannot find function createCalendar in object [Ti.Android.Calendar]. (file:///android_asset/Resources/app.js#9) E/KrollContext( 341): org.mozilla.javascript.EcmaError: TypeError: Cannot find function createCalendar in object [Ti.Android.Calendar]. (file:///android_asset/Resources/app.js#9) E/KrollContext( 341): at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3784) E/KrollContext( 341): at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3762) E/KrollContext( 341): at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3790) E/KrollContext( 341): at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3809) E/KrollContext( 341): at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3880) E/KrollContext( 341): at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2359) E/KrollContext( 341): at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2326) E/KrollContext( 341): at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1514) E/KrollContext( 341): at script(file:///android_asset/Resources/app.js:9) E/KrollContext( 341): at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) E/KrollContext( 341): at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) E/KrollContext( 341): at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) E/KrollContext( 341): at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177) E/KrollContext( 341): at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175) E/KrollContext( 341): at org.mozilla.javascript.Context.evaluateReader(Context.java:1142) E/KrollContext( 341): at org.appcelerator.titanium.kroll.KrollContext$DefaultEvaluator.evaluateFile(KrollContext.java:112) E/KrollContext( 341): at org.appcelerator.titanium.kroll.KrollContext.evaluateScript(KrollContext.java:385) E/KrollContext( 341): at org.appcelerator.titanium.kroll.KrollContext.handleEvalFile(KrollContext.java:397) E/KrollContext( 341): at org.appcelerator.titanium.kroll.KrollContext.handleMessage(KrollContext.java:296) E/KrollContext( 341): at org.appcelerator.titanium.TiMessageQueue.handleMessage(TiMessageQueue.java:223) E/KrollContext( 341): at android.os.Handler.dispatchMessage(Handler.java:95) E/KrollContext( 341): at android.os.Looper.loop(Looper.java:123) E/KrollContext( 341): at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86) E/TiJSError( 341): (kroll$1: app://app.js) [60,1668] ----- Titanium Javascript Runtime Error ----- E/TiJSError( 341): (kroll$1: app://app.js) [2,1670] - In file:///android_asset/Resources/app.js:9,0 E/TiJSError( 341): (kroll$1: app://app.js) [1,1671] - Message: TypeError: Cannot find function createCalendar in object [Ti.Android.Calendar]. (file:///android_asset/Resources/app.js#9) E/TiJSError( 341): (kroll$1: app://app.js) [1,1672] - Source: null I/TiRootActivity( 341): (main) [0,0] checkpoint, on root activity resume. context = org.appcelerator.titanium.TiContext@43e72f78 D/dalvikvm( 118): GC_EXPLICIT freed 1087 objects / 61936 bytes in 69ms D/dalvikvm( 169): GC_EXPLICIT freed 2980 objects / 186336 bytes in 77ms W/TiAnalyticsSvc( 341): (Thread-12) [28359,28359] Analytics Service Started I/TiAnalyticsSvc( 341): (Thread-12) [62,28421] Sending 1 analytics events. D/dalvikvm( 341): GC_FOR_MALLOC freed 4361 objects / 347968 bytes in 62ms D/dalvikvm( 341): GC_FOR_MALLOC freed 4144 objects / 224000 bytes in 61ms W/TiAnalyticsSvc( 341): (Thread-12) [977,29398] Stopping Analytics Service I/DeviceStorageMonitorService( 60): Memory available. Cancelling notification D/GoogleLoginService( 169): onBind: Intent { act=android.accounts.AccountAuthenticator cmp=com.google.android.gsf/.loginservice.GoogleLoginService } W/GoogleLoginService( 169): Device has no accounts: sending Intent { act=com.google.android.gsf.LOGIN_ACCOUNTS_MISSING } D/GTalkService( 169): [GTalkService.19] account missing D/KeyguardViewMediator( 60): pokeWakelock(5000) D/KeyguardViewMediator( 60): pokeWakelock(5000) I/ActivityManager( 60): Displayed activity com.appcelerator.calendar/.T12218Activity: 98371 ms (total 98371 ms) I/ARMAssembler( 60): generated scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at [0x3a95d0:0x3a96dc] in 5705000 ns I/ARMAssembler( 60): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x3a96e0:0x3a979c] in 605000 ns {noformat}

adb -d logcat

{noformat} 10-31 16:04:53.929: INFO/ActivityManager(1355): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.appcelerator.calendar/.T12218Activity } 10-31 16:04:53.959: INFO/ActivityManager(1355): Start proc com.appcelerator.calendar for activity com.appcelerator.calendar/.T12218Activity: pid=5172 uid=10072 gids={1015, 3003} 10-31 16:04:54.169: INFO/TiApplication(5172): (main) [0,0] checkpoint, app created. 10-31 16:04:54.399: INFO/TiApplication(5172): (main) [234,234] Titanium 1.8.0 (2011/10/21 18:30 e69cc8f) 10-31 16:04:54.619: INFO/TiRootActivity(5172): (main) [0,0] checkpoint, on root activity create, savedInstanceState: Bundle[mParcelledData.dataSize=204] 10-31 16:04:55.059: ERROR/TiApplication(5172): (main) [445,445] APP PROXY: [Ti.App] 10-31 16:04:55.169: DEBUG/KrollContext(5172): (kroll$1: app://app.js) [102,547] Running evaluated script: file:///android_asset/Resources/app.js 10-31 16:04:55.519: ERROR/KrollContext(5172): (kroll$1: app://app.js) [341,888] ECMA Error evaluating source: TypeError: Cannot find function createCalendar in object [Ti.Android.Calendar]. (file:///android_asset/Resources/app.js#9) 10-31 16:04:55.519: ERROR/KrollContext(5172): org.mozilla.javascript.EcmaError: TypeError: Cannot find function createCalendar in object [Ti.Android.Calendar]. (file:///android_asset/Resources/app.js#9) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3784) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3762) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3790) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3809) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3880) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2359) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2326) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1514) 10-31 16:04:55.519: ERROR/KrollContext(5172): at script(file:///android_asset/Resources/app.js:9) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.mozilla.javascript.Context.evaluateReader(Context.java:1142) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.appcelerator.titanium.kroll.KrollContext$DefaultEvaluator.evaluateFile(KrollContext.java:112) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.appcelerator.titanium.kroll.KrollContext.evaluateScript(KrollContext.java:385) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.appcelerator.titanium.kroll.KrollContext.handleEvalFile(KrollContext.java:397) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.appcelerator.titanium.kroll.KrollContext.handleMessage(KrollContext.java:296) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.appcelerator.titanium.TiMessageQueue.handleMessage(TiMessageQueue.java:223) 10-31 16:04:55.519: ERROR/KrollContext(5172): at android.os.Handler.dispatchMessage(Handler.java:95) 10-31 16:04:55.519: ERROR/KrollContext(5172): at android.os.Looper.loop(Looper.java:123) 10-31 16:04:55.519: ERROR/KrollContext(5172): at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86) 10-31 16:04:55.519: ERROR/TiJSError(5172): (kroll$1: app://app.js) [13,901] ----- Titanium Javascript Runtime Error ----- 10-31 16:04:55.519: ERROR/TiJSError(5172): (kroll$1: app://app.js) [1,902] - In file:///android_asset/Resources/app.js:9,0 10-31 16:04:55.519: ERROR/TiJSError(5172): (kroll$1: app://app.js) [1,903] - Message: TypeError: Cannot find function createCalendar in object [Ti.Android.Calendar]. (file:///android_asset/Resources/app.js#9) 10-31 16:04:55.519: ERROR/TiJSError(5172): (kroll$1: app://app.js) [0,903] - Source: null 10-31 16:04:55.609: INFO/TiRootActivity(5172): (main) [0,0] checkpoint, on root activity resume. context = org.appcelerator.titanium.TiContext@44a47c88 10-31 16:04:56.449: INFO/ActivityManager(1355): Displayed activity com.appcelerator.calendar/.T12218Activity: 2504 ms (total 2504 ms) 10-31 16:04:56.459: ERROR/msm7k.gralloc(1355): [unregister] handle 0x3068e0 still locked (state=40000001) 10-31 16:04:56.469: INFO/ActivityManager(1355): No longer want com.lge.sns (pid 5017): hidden #11 {noformat}

Tiapp.xml

{noformat} http://schemas.android.com/apk/res/android"> {noformat}

Associated HD ticket

APP-339864

Attachments

FileDateSize
calendar.jpg2011-10-31T14:26:03.000+000034492

Comments

  1. Marshall Culpepper 2011-11-17

    This isn't a bug -- We've never supported creating calendars with our API. This is a feature request.
  2. Rick Blalock 2011-11-18

    @Marshall - Ignoring the title, why are the above API's referenced in the original post undefined? They're in our docs - http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Android.Calendar-module
  3. Arthur Evans 2011-11-21

    Hi Rick, I believe the createCalendar method is a product of the old documentation system. Most proxy objects have a creator method associated with them, and the creator method doc is generated automatically unless it's suppressed. I'm not sure if the module was annotated incorrectly, or if there was simply no mechanism to mark proxy objects as not having a standard creator method. In the 1.8.0 docs, the Ti.Android.Calendar.Calendar object is marked as createable: false and the Ti.Android.Calendar.createCalendar method does not appear in the docs. This may be small consolation, but hopefully it helps explain how we ended up with a fictitious method in the API docs (and what we're doing to eliminate these in the future).
  4. Lee Morris 2017-06-07

    Closing ticket due to time passed and lack of input or progress.

JSON Source