Android-dev.it Community

 
Annunci

:arrow: Benvenuto!, se non sei ancora un utente registrato: puoi registrati qui, oppure effettua il login
:arrow: Apri un forum sul tuo nuovo smartphone Android e collabora con noi! (dettagli)

www.agendadigitale.org
Image


Sponsor
It is currently Tue May 22, 2012 7:45 am

All times are UTC + 1 hour


 Topics   Replies   Views   Last post 
No new posts На интернет-витрине

by popowahgjfghjoiuyt on Sat May 19, 2012 2:25 pm in Amministrazione

0

12

Sat May 19, 2012 2:25 pm

popowahgjfghjoiuyt

No new posts Apri un forum sul tuo nuovo smartphone Android!

[ Go to page: 1, 2, 3 ]

by ReattileGar on Fri May 18, 2012 5:27 pm in Amministrazione

27

12514

Fri May 18, 2012 5:27 pm

ReattileGar

No new posts Новый: базы для хрумера - профессиональный софт для СЕО.

by Renatafe on Fri May 18, 2012 3:14 pm in Amministrazione

0

17

Fri May 18, 2012 3:14 pm

Renatafe

No new posts Pace is undoubtedly the vital affordable Jerseys Wholesale d

by barnettmmolive2012 on Wed May 16, 2012 7:36 am in Amministrazione

1

47

Wed May 16, 2012 7:36 am

barnettmmolive2012

No new posts Problema di compatibilità app

by deran on Tue May 15, 2012 10:44 am in Sviluppo e programmazione in Android

4

200

Tue May 15, 2012 10:44 am

deran




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: come accededere agli elementi memorizzati nell'agenda
PostPosted: Tue Feb 08, 2011 10:11 am 
Offline
User avatar

Joined: Tue Feb 08, 2011 9:54 am
Posts: 5
Cellulare Android: HTC Dream
Operatore: Wind
Punti Android: ?
Ciao ragazzi, vorrei sapere com'è possibile accedere agli iimpegni della giornata memorizzati nell'agenda di un cellulare android per poi parsarli ed eseguire varie altre operazioni su di essi tramite l'SDK


Top
 Profile  
 
 Post subject: Re: come accededere agli elementi memorizzati nell'agenda
PostPosted: Tue Feb 15, 2011 2:35 pm 
Offline
User avatar

Joined: Thu Dec 27, 2007 7:09 pm
Posts: 659
Cellulare Android: HTC Dream
Operatore: TIM
Punti Android: 758
Ciao,
in generale, la piattaforma Android mette a disposizione i cosi' detti ***URLs are hidden from guests, please register and login to view the hyperlink*** per consentire alle applicazioni di accedere alle informazioni contenute nei diversi database SQLite (di sistema o proprietari di un'applicazione): li puoi vedere come un modo "standard" per interfacciarsi con i dati senza dover gestire le cose a basso livello (apertura database, query SQL, ecc.), quindi come una sorta di API.

Ad esempio per accedere alle info contenute nell'agenda dei contatti, si può usare ***URLs are hidden from guests, please register and login to view the hyperlink***
Per fare quello che interessa a te, invece, puoi usare android.provider.Calendar, anche se quest'ultimo non è un ContentProvider "ufficiale" (non è documentato).

Ricordati che per avere accesso alle informazioni del calendario è necessario impostare i permessi seguenti nel file Manifest.xml
Code:
<uses-permission  android:name="android.permission.READ_CALENDAR"> </uses-permission>
<uses-permission   android:name="android.permission.WRITE_CALENDAR"> </uses-permission>


Prima di qualsiasi altra cosa, è necessario conoscere quali calendar sono presenti nel sistema e quali sono i relativi ID, per far questo, puoi usare questo snippet di codice:
Code:
Cursor cursor = cr.query(Uri.parse("content://calendar/calendars"), new String[]{ "_id", "displayname" }, null, null, null);
cursor.moveToFirst();
String[] CalNames = new String[cursor.getCount()];
int[] CalIds = new int[cursor.getCount()];
for (int i = 0; i < CalNames.length; i++) {
    CalIds[i] = cursor.getInt(0);
    CalNames[i] = cursor.getString(1);
    cursor.moveToNext();
}
cursor.close();


Per aggoiungere un evento, puoi usare questo snippet di codice:
Code:
ContentValues cv = new ContentValues();
cv.put("calendar_id", CalIds[0]);
cv.put("title", myTitle);
cv.put("dtstart", startTime);
cv.put("dtend", endTime);
cv.put("eventLocation", myLocation);
URI newevent = cr.insert(Uri.parse("content://calendar/events"), cv);


Per aggiungere un reminder all'evento che è stato appena creato, puoi invece usare questo snippet di codice:
Code:
String eventid = newevent.getPathSegments().get(newevent.getPathSegments().size()-1);
cv.put("event_id",eventid);
cv.put("minutes",interval);
cr.insert(Uri.parse(content://calendar/reminders"),cv);


Trovi altre info utili qui: ***URLs are hidden from guests, please register and login to view the hyperlink***

_________________
***URLs are hidden from guests, please register and login to view the hyperlink***


Top
 Profile  
 
 Post subject: Re: come accededere agli elementi memorizzati nell'agenda
PostPosted: Tue Jan 10, 2012 3:36 pm 
Offline
User avatar

Joined: Sat Nov 19, 2011 5:41 pm
Posts: 5
Punti Android: 6
Scusami tanto,

ma per cosa sta "cr"?

Non riesco a capire..

Grazie mille


Top
 Profile  
 
 Post subject: Re: come accededere agli elementi memorizzati nell'agenda
PostPosted: Wed Feb 08, 2012 4:16 pm 
Offline
Moderatore
User avatar

Joined: Thu Dec 27, 2007 3:51 pm
Posts: 986
Cellulare Android: HTC Dream
Operatore: TIM
Punti Android: 1320
Nello snippet che ti ho riportato, cr è un'istanza della classe Content Resolver:
Code:
ContentResolver cr = getContentResolver();


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
SitemapIndex SitemapIndex RSS Feed RSS Feed Channel list Channel list
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
phpBB SEO

All trademarks and logos used in this site are of properties of their respective owners.