baynes.kathleen.contacts.1's Introduction
It's the last contacts application... finally! Now we'll use the real Android Contacts provider to store your contact data. We'll also add a few notifications to try them out. Your application should behave as follows: Whenever an entry is created: Display a Toast stating "contact created" Add a notification stating "Contact <name> was added to your contact list". This notification should auto-close when clicked, and display your "display contact" activity for the added contact. (Note that pressing "back" from this contact display will go back to wherever the user was when they selected the notification; it will not go back to the contact list) Whenever an entry is updated: Display a Toast stating "contact updated" Add a notification stating "Contact <name> was updated". This notification should auto-close when clicked, and display your "display contact" activity for the added contact. (Note that pressing "back" from this contact display will go back to wherever the user was when they selected the notification; it will not go back to the contact list) (Note 1: I don't recommend using both a Toast and a notification like this; it's obnoxious, but this allows you to see how each of them behave) (Note 2: I recommend you get the notification part of the assignment out of the way before changing your data storage to use the contacts provider) Modify your application to use the Android Contacts content provider to retrieve, insert and update contacts. A few notes on this: The Android "display name" is different than what we've been using. Ours is more like a "nickname". Focus first on getting the list of contacts displayed. Feel free to use SimpleCursorAdapter to display just the android display name. Add contacts through the normal Android Contacts application and you should see them listed in your UI. When you initially set up to read the data for display, skip your custom fields (displayName, birthday and contact times) for now. Add them back in after you implement the insert/update support. Next, retrieve all data for a contact. You'll need to use the following content URIs: ContactsContract.Data.CONTENT_URI - to get your extension data and ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME (first name) ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME (last name) Note that for the names you'll use mime type ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE for your extension data, you'll use your custom mime type ContactsContract.CommonDataKinds.Phone.CONTENT_URI - to get the phone numbers. Look for phone numbers assigned with the following types. You can assume there's only a single phone number of each type for this assignment: ContactsContract.CommonDataKinds.Phone.TYPE_HOME ContactsContract.CommonDataKinds.Phone.TYPE_WORK ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE ContactsContract.CommonDataKinds.Email.CONTENT_URI - for email addresses. Assume there's only one ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_URI - for postal address. Again, assume there's only one. Use its ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS for the value. Not quite right, but good enough for this assignment. Use a custom mime type for your display name, birthday and contact times. You can store these in a single data row, or multiple data rows. Next, add in insert support.. Use ContentProviderOperation as demonstrated in class. Finally, add in update support. Again, use ContentProviderOperation, but with newUpdate and .withSelection() instead of newInsert() and .withValueBackReference(). Note that this assignment may take a little time to implement... Getting the details right when using the content provider can take a little trial and error...
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.