Note that there are some explanatory texts on larger screens.

plurals
  1. POBroadcast Receiver for multiple database Cursor
    primarykey
    data
    text
    <p>I have been stuck on this problem for a while.</p> <p>Is there any good example for Broadcast Receiver with multiple database Cursor?</p> <p>PROBLEM: I have implemented PagerTabStrip, and also BroadCast receiver and notification for reminder. </p> <p>So when I click on notification on device screen, it only opens the first cursor, it doesnt open the other too.. I am pretty sure that, I have closed my cursors.</p> <p>THIS IS JUST OPENS UP THE BLANK ACTIVITY without and STUFF I WANT. </p> <pre><code>public class ReminderService extends WakeReminderIntentService{ public ReminderService(){ super("ReminderService"); } @SuppressWarnings("deprecation") void doReminderWork(Intent intent){ Log.d("ReminderService", "Doing work."); Long rowId = intent.getExtras().getLong(TaskDatabase.KEY_ROWID); NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(this, TaskEdit.class); notificationIntent.putExtra(TaskDatabase.KEY_ROWID, rowId); PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT); </code></pre> <p>/// Rest of the COde.</p> <p>BROADCASTRECEIVER(this class gets the cursor)</p> <pre><code>public void onReceive(Context context, Intent intent){ ReminderManager reminderMgr = new ReminderManager(context); TaskDatabase dbHelper = new TaskDatabase(context); dbHelper.open(); Cursor cursor = dbHelper.fetchAllGeneralRemindersByDefault(); if(cursor != null){ cursor.moveToFirst(); int rowIdColumnIndex = cursor.getColumnIndex(TaskDatabase.KEY_ROWID); int dateTimeColumnIndex = cursor.getColumnIndex(TaskDatabase.KEY_DATE_TIME); while(cursor.isAfterLast() == false){ Log.d(TAG, "Adding alarm from boot."); Log.d(TAG, "Row Id Column Index - " + rowIdColumnIndex); Log.d(TAG, "Date Time Column Index - " + dateTimeColumnIndex); Long rowId = cursor.getLong(rowIdColumnIndex); String dateTime = cursor.getString(dateTimeColumnIndex); Calendar cal = Calendar.getInstance(); SimpleDateFormat format = new SimpleDateFormat(TaskEdit.DATE_TIME_FORMAT); try{ java.util.Date date = format.parse(dateTime); cal.setTime(date); reminderMgr.setReminder(rowId, cal); }catch(java.text.ParseException e){ Log.e("OnBootReceiver", e.getMessage(), e); } cursor.moveToNext(); } </code></pre>
    singulars
    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