Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8439] Android: Unable to get any results when pulling events by date range

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-04-17T20:27:14.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sRelease 2.1.0, Sprint 2012-08
ComponentsAndroid
LabelsSupportTeam, api
ReporterEduardo Gomez
AssigneePing Wang
Created2012-03-30T09:05:24.000+0000
Updated2017-03-21T20:42:37.000+0000

Description

Issue

Exception is thrown as Android is unable to get any results when pulling events by date range

Tested on

sdk-version: 2.1.0.v20120329000337

Runtime engines

Same thing happens with V8 and Rhino.

Device

Galaxy Tab 7 Plus model GT-P6210 Android version 3.2 Kernel 2.6.36-P6210UEKJC-CL567728 se.infra@SEI-20 #3

Repro sequence

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


var win = Titanium.UI.createWindow({  
    title:'Calendar',
    backgroundColor:'#fff'
});
win.open();



  

  var startDate = new Date();
  startDate.setFullYear(startDate.getFullYear()-1,0,1); 

  Ti.API.info('startDate: '+startDate);

  var endDate = new Date();
  endDate.setFullYear(endDate.getFullYear()+1,0,1); 
  Ti.API.info('endDate: '+endDate);



function showCalendars(calendars) {
    for (var i = 0; i < calendars.length; i++) {
        Ti.API.info(calendars[i].name);
    Ti.API.info(JSON.stringify(calendars[i]));
    }
}
 
Ti.API.info('ALL CALENDARS:');
showCalendars(Ti.Android.Calendar.allCalendars);
Ti.API.info('SELECTABLE CALENDARS:');
showCalendars(Ti.Android.Calendar.selectableCalendars);

var out = [];

Ti.API.info('TRY TO GET EVENTS IN ALL CALENDARS:');
var calendars = Ti.Android.Calendar.allCalendars

Ti.API.info(JSON.stringify(calendars));
for (var i=0; i < calendars.length; i++) {
  Ti.API.info(JSON.stringify(calendars[i]));

    try {
      var cal_events = calendars[i].getEventsBetweenDates(startDate,endDate);

      for (var j=0; j < cal_events.length; j++) {
        out.push(cal_events[j]);
      };
      
    }
    catch(err) {
      Ti.API.error("ERROR "+err);
    }

};





Ti.API.info('TRY TO GET EVENTS IN SELECTABLE CALENDARS:');

var calendars = Ti.Android.Calendar.selectableCalendars

Ti.API.info(JSON.stringify(calendars));
for (var i=0; i < calendars.length; i++) {
  Ti.API.info(JSON.stringify(calendars[i]));
  try {
    var cal_events = calendars[i].getEventsBetweenDates(startDate,endDate);

    for (var j=0; j < cal_events.length; j++) {
      out.push(cal_events[j]);
    };
    
  }
  catch(err) {
    Ti.API.error("ERROR "+err);
  }
};

Ti.API.info('ALL THE EVENTS:');
Ti.API.info(JSON.stringify(out));

Console output

03-30 10:49:38.935: I/TiApplication(23751): (main) [98,98] Titanium 2.1.0 (2012/03/29 00:04 ac3852d)
03-30 10:49:38.945: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:38.955: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:38.960: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:38.975: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:38.995: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.010: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.025: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.035: D/dalvikvm(23751): GC_CONCURRENT freed 281K, 6% free 6505K/6919K, paused 1ms+1ms
03-30 10:49:39.040: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.055: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.075: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.080: D/dalvikvm(23751): Trying to load lib /data/data/info.rborn.calendar/lib/libstlport_shared.so 0x4079b9e0
03-30 10:49:39.080: I/TiApplication(23751): (main) [146,244] Titanium Javascript runtime: v8
03-30 10:49:39.080: D/dalvikvm(23751): Added shared lib /data/data/info.rborn.calendar/lib/libstlport_shared.so 0x4079b9e0
03-30 10:49:39.080: D/dalvikvm(23751): No JNI_OnLoad found in /data/data/info.rborn.calendar/lib/libstlport_shared.so 0x4079b9e0, skipping init
03-30 10:49:39.080: D/dalvikvm(23751): Trying to load lib /data/data/info.rborn.calendar/lib/libkroll-v8.so 0x4079b9e0
03-30 10:49:39.090: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.090: I/TiRootActivity(23751): (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
03-30 10:49:39.095: D/dalvikvm(23751): Added shared lib /data/data/info.rborn.calendar/lib/libkroll-v8.so 0x4079b9e0
03-30 10:49:39.105: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.120: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.140: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.140: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.140: I/LiveWallpaper(2895): Engine.onVisibilityChanged() - false
03-30 10:49:39.140: I/SurfaceFlinger(2698): id=1870 Removed com.android.launcher/com.android.launcher2.Launcher idx=2 Map Size=3
03-30 10:49:39.150: I/SurfaceFlinger(2698): id=1870 Removed com.android.launcher/com.android.launcher2.Launcher idx=-2 Map Size=3
03-30 10:49:39.390: E/TiApplication(23751): (KrollRuntimeThread) [298,298] APP PROXY: ti.modules.titanium.app.AppModule@407b5cd0
03-30 10:49:39.485: I/TiAPI(23751): startDate: Sat Jan 01 2011 10:49:39 GMT+0100 (CET)
03-30 10:49:39.485: I/TiAPI(23751): endDate: Tue Jan 01 2013 10:49:39 GMT+0100 (CET)
03-30 10:49:39.485: I/TiAPI(23751): ALL CALENDARS:
03-30 10:49:39.495: I/TiAPI(23751): My calendar
03-30 10:49:39.495: I/TiAPI(23751): {"hidden":false,"id":"1","selected":true,"name":"My calendar"}
03-30 10:49:39.495: I/TiAPI(23751): dan.tamas.tst@gmail.com
03-30 10:49:39.495: I/TiAPI(23751): {"hidden":false,"id":"2","selected":true,"name":"dan.tamas.tst@gmail.com"}
03-30 10:49:39.495: I/TiAPI(23751): dan tamas
03-30 10:49:39.500: I/TiAPI(23751): {"hidden":false,"id":"3","selected":true,"name":"dan tamas"}
03-30 10:49:39.500: I/TiAPI(23751): test 1
03-30 10:49:39.500: I/TiAPI(23751): {"hidden":false,"id":"4","selected":true,"name":"test 1"}
03-30 10:49:39.500: I/TiAPI(23751): test 1
03-30 10:49:39.500: I/TiAPI(23751): {"hidden":false,"id":"5","selected":true,"name":"test 1"}
03-30 10:49:39.500: I/TiAPI(23751): test 2
03-30 10:49:39.500: I/TiAPI(23751): {"hidden":false,"id":"6","selected":true,"name":"test 2"}
03-30 10:49:39.500: I/TiAPI(23751): SELECTABLE CALENDARS:
03-30 10:49:39.505: I/TiAPI(23751): My calendar
03-30 10:49:39.505: I/TiAPI(23751): {"hidden":false,"id":"1","selected":true,"name":"My calendar"}
03-30 10:49:39.505: I/TiAPI(23751): dan.tamas.tst@gmail.com
03-30 10:49:39.505: I/TiAPI(23751): {"hidden":false,"id":"2","selected":true,"name":"dan.tamas.tst@gmail.com"}
03-30 10:49:39.505: I/TiAPI(23751): dan tamas
03-30 10:49:39.505: I/TiAPI(23751): {"hidden":false,"id":"3","selected":true,"name":"dan tamas"}
03-30 10:49:39.505: I/TiAPI(23751): test 1
03-30 10:49:39.505: I/TiAPI(23751): {"hidden":false,"id":"4","selected":true,"name":"test 1"}
03-30 10:49:39.505: I/TiAPI(23751): test 1
03-30 10:49:39.505: I/TiAPI(23751): {"hidden":false,"id":"5","selected":true,"name":"test 1"}
03-30 10:49:39.505: I/TiAPI(23751): test 2
03-30 10:49:39.505: I/TiAPI(23751): {"hidden":false,"id":"6","selected":true,"name":"test 2"}
03-30 10:49:39.505: I/TiAPI(23751): TRY TO GET EVENTS IN ALL CALENDARS:
03-30 10:49:39.515: I/TiAPI(23751): [{"hidden":false,"id":"1","selected":true,"name":"My calendar"},{"hidden":false,"id":"2","selected":true,"name":"dan.tamas.tst@gmail.com"},{"hidden":false,"id":"3","selected":true,"name":"dan tamas"},{"hidden":false,"id":"4","selected":true,"name":"test 1"},{"hidden":false,"id":"5","selected":true,"name":"test 1"},{"hidden":false,"id":"6","selected":true,"name":"test 2"}]
03-30 10:49:39.515: I/TiAPI(23751): {"hidden":false,"id":"1","selected":true,"name":"My calendar"}
03-30 10:49:39.520: W/TiEvent(23751): (KrollRuntimeThread) [132,430] unable to get any results when pulling events by date range
03-30 10:49:39.520: I/TiAPI(23751): {"hidden":false,"id":"2","selected":true,"name":"dan.tamas.tst@gmail.com"}
03-30 10:49:39.525: W/TiEvent(23751): (KrollRuntimeThread) [4,434] unable to get any results when pulling events by date range
03-30 10:49:39.525: I/TiAPI(23751): {"hidden":false,"id":"3","selected":true,"name":"dan tamas"}
03-30 10:49:39.525: W/TiEvent(23751): (KrollRuntimeThread) [2,436] unable to get any results when pulling events by date range
03-30 10:49:39.525: I/TiAPI(23751): {"hidden":false,"id":"4","selected":true,"name":"test 1"}
03-30 10:49:39.530: W/TiEvent(23751): (KrollRuntimeThread) [3,439] unable to get any results when pulling events by date range
03-30 10:49:39.530: I/TiAPI(23751): {"hidden":false,"id":"5","selected":true,"name":"test 1"}
03-30 10:49:39.530: W/TiEvent(23751): (KrollRuntimeThread) [3,442] unable to get any results when pulling events by date range
03-30 10:49:39.535: I/TiAPI(23751): {"hidden":false,"id":"6","selected":true,"name":"test 2"}
03-30 10:49:39.535: W/TiEvent(23751): (KrollRuntimeThread) [3,445] unable to get any results when pulling events by date range
03-30 10:49:39.535: I/TiAPI(23751): TRY TO GET EVENTS IN SELECTABLE CALENDARS:
03-30 10:49:39.540: I/TiAPI(23751): [{"hidden":false,"id":"1","selected":true,"name":"My calendar"},{"hidden":false,"id":"2","selected":true,"name":"dan.tamas.tst@gmail.com"},{"hidden":false,"id":"3","selected":true,"name":"dan tamas"},{"hidden":false,"id":"4","selected":true,"name":"test 1"},{"hidden":false,"id":"5","selected":true,"name":"test 1"},{"hidden":false,"id":"6","selected":true,"name":"test 2"}]
03-30 10:49:39.540: I/TiAPI(23751): {"hidden":false,"id":"1","selected":true,"name":"My calendar"}
03-30 10:49:39.545: W/TiEvent(23751): (KrollRuntimeThread) [8,453] unable to get any results when pulling events by date range
03-30 10:49:39.545: I/TiAPI(23751): {"hidden":false,"id":"2","selected":true,"name":"dan.tamas.tst@gmail.com"}
03-30 10:49:39.545: W/TiEvent(23751): (KrollRuntimeThread) [3,456] unable to get any results when pulling events by date range
03-30 10:49:39.545: I/TiAPI(23751): {"hidden":false,"id":"3","selected":true,"name":"dan tamas"}
03-30 10:49:39.550: W/TiEvent(23751): (KrollRuntimeThread) [3,459] unable to get any results when pulling events by date range
03-30 10:49:39.550: I/TiAPI(23751): {"hidden":false,"id":"4","selected":true,"name":"test 1"}
03-30 10:49:39.550: W/TiEvent(23751): (KrollRuntimeThread) [3,462] unable to get any results when pulling events by date range
03-30 10:49:39.550: I/TiAPI(23751): {"hidden":false,"id":"5","selected":true,"name":"test 1"}
03-30 10:49:39.555: W/TiEvent(23751): (KrollRuntimeThread) [3,465] unable to get any results when pulling events by date range
03-30 10:49:39.555: I/TiAPI(23751): {"hidden":false,"id":"6","selected":true,"name":"test 2"}
03-30 10:49:39.560: W/TiEvent(23751): (KrollRuntimeThread) [2,467] unable to get any results when pulling events by date range
03-30 10:49:39.560: I/TiAPI(23751): ALL THE EVENTS:
03-30 10:49:39.560: I/TiAPI(23751): []
03-30 10:49:39.590: D/dalvikvm(23751): GC_FOR_ALLOC freed 246K, 6% free 6610K/6983K, paused 13ms
03-30 10:49:39.590: I/dalvikvm-heap(23751): Grow heap (frag case) to 7.996MB for 1536016-byte allocation
03-30 10:49:39.620: D/dalvikvm(23751): GC_FOR_ALLOC freed <1K, 5% free 8109K/8519K, paused 12ms
03-30 10:49:39.620: W/CursorWrapperInner(23751): Cursor finalized without prior close()
03-30 10:49:39.645: W/CursorWrapperInner(23751): Cursor finalized without prior close()
03-30 10:49:39.645: D/dalvikvm(23751): GC_CONCURRENT freed 1K, 5% free 8108K/8519K, paused 1ms+1ms
03-30 10:49:39.645: W/CursorWrapperInner(23751): Cursor finalized without prior close()
03-30 10:49:39.645: W/CursorWrapperInner(23751): Cursor finalized without prior close()
03-30 10:49:39.670: D/dalvikvm(23751): GC_FOR_ALLOC freed 14K, 5% free 8094K/8519K, paused 12ms
03-30 10:49:39.670: I/dalvikvm-heap(23751): Grow heap (frag case) to 8.630MB for 682256-byte allocation
03-30 10:49:39.690: D/dalvikvm(23751): GC_FOR_ALLOC freed 0K, 6% free 8760K/9223K, paused 12ms
03-30 10:49:39.725: D/dalvikvm(23751): GC_CONCURRENT freed 0K, 6% free 8760K/9223K, paused 1ms+1ms
03-30 10:49:39.730: I/TiRootActivity(23751): (main) [0,0] checkpoint, on root activity resume. activity = info.rborn.calendar.CalendartestActivity@407f22c8
03-30 10:49:39.735: D/WindowManager(2827): addWindowToListInOrder() : current mSkipWidgetFocus='true'
03-30 10:49:39.740: I/SurfaceFlinger(2698): id=1872(1) createSurface 0x40514 for pid 23751 (1x1),2 flag=0, info.rborn.calendar/info.rborn.calendar.CalendartestActivity
03-30 10:49:39.745: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.750: I/WindowManager(2827): Putting input method here!
03-30 10:49:39.750: D/WindowManager(2827):     w.mAttrs.token=ActivityRecord{40decca0 info.rborn.calendar/.CalendartestActivity}
03-30 10:49:39.750: D/WindowManager(2827):     w.mToken=AppWindowToken{41ae2ef8 token=ActivityRecord{40decca0 info.rborn.calendar/.CalendartestActivity}}
03-30 10:49:39.750: D/WindowManager(2827): Desired input method target: Window{40ba9a60 info.rborn.calendar/info.rborn.calendar.CalendartestActivity paused=false}
03-30 10:49:39.750: D/WindowManager(2827): Current focus: Window{40ba9a60 info.rborn.calendar/info.rborn.calendar.CalendartestActivity paused=false}
03-30 10:49:39.750: D/WindowManager(2827): Last focus: Window{40ba9a60 info.rborn.calendar/info.rborn.calendar.CalendartestActivity paused=false}
03-30 10:49:39.750: D/WindowManager(2827): IM target client: com.android.internal.view.IInputMethodClient$Stub$Proxy@41040b20
03-30 10:49:39.750: D/WindowManager(2827): IM target client binder: android.os.BinderProxy@41066c90
03-30 10:49:39.750: D/WindowManager(2827): Requesting client binder: android.os.BinderProxy@41066c90
03-30 10:49:39.750: D/CLIPBOARD(4466): Hide Clipboard dialog at Starting input: finished by someone else... !
03-30 10:49:39.750: W/CPUclock(2827):  mDVFSUpperLock.release()
03-30 10:49:39.750: D/CLIPBOARD(2827): Hide Clipboard dialog inside hideSoftInput() !
03-30 10:49:39.750: D/CLIPBOARD(2827): Hide Clipboard dialog inside windowGainedFocus() !
03-30 10:49:39.750: D/WindowManager(2827):     token=AppWindowToken{41ae2ef8 token=ActivityRecord{40decca0 info.rborn.calendar/.CalendartestActivity}}
03-30 10:49:39.750: I/WindowManager(2827): Placing input method @10
03-30 10:49:39.765: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.765: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.765: I/ActivityManager(2827): Displayed info.rborn.calendar/.CalendartestActivity: +1s156ms
03-30 10:49:39.765: D/CLIPBOARD(23751): Hide Clipboard dialog at Starting input: finished by someone else... !
03-30 10:49:39.770: D/KeyguardViewMediator(2827): setHidden false
03-30 10:49:39.770: D/TabletStatusBar(2886): lights on

Comments

  1. Eduardo Gomez 2012-04-12

    Having a data less than 2 years (any other dates) it behaves the same. So the workaround for customer is to split the time range in segments less than 24 month - 2days.

    In the next range anything greater than this end date will return an error.

       04-12 22:37:02.465: I/TiAPI(18524): startDate: Sun Jan 01 2012 22:37:02 GMT-0000 (GMT)
       04-12 22:37:02.465: I/TiAPI(18524): endDate: Sat Dec 28 2013 22:37:02 GMT-0000 (GMT)
       
  2. Olga Romero 2013-01-18

    Running this code, I can see database error and permission error. Need an updated test case to make an alignment with a current SDK. Tested with: Titanium Studio, build: 3.0.1.201212181159 Titanium SDK, build: 3.0.2.v20130117161659 Device: HTC-EVO Android version 4.0.3
  3. Lee Morris 2017-03-21

    Closing ticket as fixed.

JSON Source