Chronogps Posted May 14, 2012 Share Posted May 14, 2012 Je galère sur cette portion de code (trouvé ici : http://developer.and...r-provider.html ) Ca crash sur cur = cr.query(uri, EVENT_PROJECTION, selection, selectionArgs, null); Et je ne vois pas pourquoi. Une idée ? Le programme plante en debug direct sur ma tablette Acer A500 sous ICS 4.0.3 (apparemment il n'est pas possible de synchroniser l'agenda sur l'émulateur) J'ai bien entendu aménagé en conséquence le androidmanifest.xml <uses-permission android:name="android.permisson.READ_CALENDAR"/> <uses-permission android:name="android.permisson.WRITE_CALENDAR"/> final int PROJECTION_ID_INDEX = 0; final int PROJECTION_ACCOUNT_NAME_INDEX = 1; final int PROJECTION_DISPLAY_NAME_INDEX = 2; final int PROJECTION_OWNER_ACCOUNT_INDEX = 3; // Projection array. Creating indices for this array instead of doing // dynamic lookups improves performance. final String[] EVENT_PROJECTION = new String[] { Calendars._ID, // 0 Calendars.ACCOUNT_NAME, // 1 Calendars.CALENDAR_DISPLAY_NAME // 2 }; // Run query Cursor cur = null; ContentResolver cr = getContentResolver(); Uri uri = Calendars.CONTENT_URI; String selection = "((" + Calendars.ACCOUNT_NAME + " = ?) AND (" + Calendars.ACCOUNT_TYPE + " = ?))"; String[] selectionArgs = new String[] {"chronogps@gmail.com", "com.google"}; // Submit the query and get a Cursor object back. cur = cr.query(uri, EVENT_PROJECTION, selection, selectionArgs, null); // Use the cursor to step through the returned records while (cur.moveToNext()) { long calID = 0; String displayName = null; String accountName = null; // Get the field values calID = cur.getLong(PROJECTION_ID_INDEX); displayName = cur.getString(PROJECTION_DISPLAY_NAME_INDEX); accountName = cur.getString(PROJECTION_ACCOUNT_NAME_INDEX); // Do something with the values... } Link to comment Share on other sites More sharing options...
Chronogps Posted May 16, 2012 Author Share Posted May 16, 2012 Grossière erreur de ma part... faute de frappe sur permisson... Honte a moi et sur les 5 générations à venir ! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.