I am trying to write some code that can tell if the reminders on an event were 
changed (either one added or removed) but I'm getting a weird occurrence. 
Instead of the reminder being removed or altered, it appears the event is being 
removed and re-added! Is my code incorrect? Or is this what's really occurring?

To test this, you'll need to:

1. create an event with a reminder
2. click the button after that syncs t your emulator
3. Remove the reminder on the event
4. Wait till that change syncs to your emulator and then click the button again

**JAVA CODE**
package com.example.remindertest;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.database.Cursor;
import android.net.Uri;
import android.provider.CalendarContract.CalendarAlerts;
import android.provider.CalendarContract.Events;
import android.provider.CalendarContract.Instances;
import android.provider.CalendarContract.Reminders;
import android.util.Log;
import android.view.View;

public class ReminderActivity extends Activity 
{
    final static public String TAG = "ReminderActivity";
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        //Add button
        setContentView(R.layout.reminder_activity);
        Log.d(TAG, "Started");
    }
    
    public void onClick(View v)
    {
        Cursor cursor = getContentResolver().query( 
                Reminders.CONTENT_URI, 
                null, null, null, null
        );
        
        String str = "";
        
        /*
         * Some crappy code to test this
         */
        while ( cursor.moveToNext())
        {
            int eventId = 
cursor.getInt(cursor.getColumnIndex(Reminders.EVENT_ID));
            Cursor eCursor = getContentResolver().query(
                    Events.CONTENT_URI, 
                    new String[] { Events._ID, Events.TITLE },
                    "_id = ?", new String[] {"" + eventId}, ( String ) null);
            
            eCursor.moveToNext();
            String title = 
eCursor.getString(eCursor.getColumnIndex(Events.TITLE));
            
            str += eventId + " = " + title + " = " + 
                    cursor.getInt(cursor.getColumnIndex(Reminders._ID)) + " = " 
+
                    cursor.getInt(cursor.getColumnIndex(Reminders.METHOD)) + " 
= " +
                    cursor.getLong(cursor.getColumnIndex(Reminders.MINUTES)) + 
"\n";
        }
        
        Log.d(TAG, str);
    }
}


**LAYOUT XML**

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android";
    xmlns:tools="http://schemas.android.com/tools";
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ReminderActivity" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="98dp"
        android:onClick="onClick"
        android:text="Button" />

</RelativeLayout>

**MANIFEST XML**

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
    package="com.example.remindertest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="17" />
    
    <uses-permission android:name="android.permission.READ_CALENDAR"/>
    <uses-permission android:name="android.permission.WRITE_CALENDAR"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.remindertest.ReminderActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to