Aller au contenu
View in the app

A better way to browse. Learn more.

Forum de Frandroid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[ICS] Lecture des données de l'agenda : Crash sur query

Featured Replies

Posté(e)

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...
}  

Posté(e)
  • Auteur

Grossière erreur de ma part... faute de frappe sur permisson... Honte a moi et sur les 5 générations à venir !

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Account

Navigation

Rechercher

Rechercher

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.