Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to set alarm manually
    primarykey
    data
    text
    <p>I am using Remainder in my App. I have to get the events from the database and the set the details into calendar for setting alarm with Push message. I have tried some code.</p> <p>but i could not set the calender manual. Getting Null pointer exception. My code is here:</p> <pre><code>scheduleClient = new ScheduleClient(this); scheduleClient.doBindService(); Calendar c = Calendar.getInstance(); String month = String.valueOf(c.get(Calendar.MONTH) + 1); String year = String.valueOf(c.get(Calendar.YEAR)); String months = null; if (month.startsWith("0") || month.startsWith("1")) { months = year + "-" + month; } else { months = year + "-" + "0" + month; } if (isSetToTrue == true) { LoadCalender(months); // here set your checkBox to true Toast.makeText(this, "Check box enabled", Toast.LENGTH_SHORT) .show(); } else { Toast.makeText(this, "Check box disabled", Toast.LENGTH_SHORT) .show(); } public void LoadCalender(String month) { try { Cursor cursor = null; Database db = new Database(getApplicationContext()); cursor = db.getSelectedEventDetails(month); if (cursor.getCount() != 0) { if (cursor.moveToFirst()) { do { text = cursor.getString(cursor.getColumnIndex("event")); title = "News/Events"; String dates = cursor.getString(cursor .getColumnIndex("date")); try { DateFormat formatter; Date date = new Date(); formatter = new SimpleDateFormat("yyyy-MM-dd"); date = (Date) formatter.parse(dates); SimpleDateFormat fmt = new SimpleDateFormat( "yyyy-MM-dd"); String todayStr = fmt.format(date); java.sql.Date dt = java.sql.Date .valueOf(new String(todayStr)); System.out.println("Today is " + dt); String yr = String.valueOf(dt.getYear()); int year = Integer.parseInt("20"+yr.substring(1)); int months = dt.getMonth(); int day = dt.getDay(); Calendar c1 = Calendar.getInstance(); c1.set(year, months+1, day); c1.set(Calendar.HOUR_OF_DAY, 0); c1.set(Calendar.MINUTE, 0); c1.set(Calendar.SECOND, 0); // Ask our service to set an alarm for that date, // this // activity talks to the client that talks to the // service scheduleClient.setAlarmForNotification(c1); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } while (cursor.moveToNext()); } } cursor.close(); } catch (Exception e) { e.printStackTrace(); } // looping through All Contacts } </code></pre> <p>Logcat error;</p> <pre><code> 03-19 12:23:23.395: W/System.err(2984): java.lang.NullPointerException 03-19 12:23:23.405: W/System.err(2984): at com.rathnasoft.reminder.ScheduleClient.setAlarmForNotification(ScheduleClient.java:54) 03-19 12:23:23.426: W/System.err(2984): at com.rathnasoft.vikasa.HomeActivity.LoadCalender(HomeActivity.java:228) 03-19 12:23:23.446: W/System.err(2984): at com.rathnasoft.vikasa.HomeActivity.onCreate(HomeActivity.java:87) 03-19 12:23:23.466: W/System.err(2984): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 03-19 12:23:23.475: W/System.err(2984): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) 03-19 12:23:23.506: W/System.err(2984): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 03-19 12:23:23.518: W/System.err(2984): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 03-19 12:23:23.525: W/System.err(2984): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 03-19 12:23:23.556: W/System.err(2984): at android.os.Handler.dispatchMessage(Handler.java:99) 03-19 12:23:23.577: W/System.err(2984): at android.os.Looper.loop(Looper.java:130) 03-19 12:23:23.586: W/System.err(2984): at android.app.ActivityThread.main(ActivityThread.java:3683) 03-19 12:23:23.615: W/System.err(2984): at java.lang.reflect.Method.invokeNative(Native Method) 03-19 12:23:23.635: W/System.err(2984): at java.lang.reflect.Method.invoke(Method.java:507) 03-19 12:23:23.645: W/System.err(2984): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 03-19 12:23:23.666: W/System.err(2984): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 03-19 12:23:23.676: W/System.err(2984): at dalvik.system.NativeStart.main(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload