1 page.title= 2 @jd:body 3 <div id="qv-wrapper"> 4 <div id="qv"> 5 <h2></h2> 6 <ul> 7 <li>Android </li> 8 <li> 9 10 </li> 11 <li> 12 13 </li> 14 </ul> 15 <h2></h2> 16 <ol> 17 <li> 18 <a href="#InformationTypes"></a> 19 </li> 20 <li> 21 <a href="#RawContactBasics"></a> 22 </li> 23 <li> 24 <a href="#DataBasics"></a> 25 </li> 26 <li> 27 <a href="#ContactBasics"></a> 28 </li> 29 <li> 30 <a href="#Sources"></a> 31 </li> 32 <li> 33 <a href="#Permissions"></a> 34 </li> 35 <li> 36 <a href="#UserProfile"></a> 37 </li> 38 <li> 39 <a href="#ContactsProviderMetadata"></a> 40 </li> 41 <li> 42 <a href="#Access"></a> 43 <li> 44 </li> 45 <li> 46 <a href="#SyncAdapters"></a> 47 </li> 48 <li> 49 <a href="#SocialStream"></a> 50 </li> 51 <li> 52 <a href="#AdditionalFeatures"></a> 53 </li> 54 </ol> 55 <h2></h2> 56 <ol> 57 <li>{@link android.provider.ContactsContract.Contacts}</li> 58 <li>{@link android.provider.ContactsContract.RawContacts}</li> 59 <li>{@link android.provider.ContactsContract.Data}</li> 60 <li>{@code android.provider.ContactsContract.StreamItems}</li> 61 </ol> 62 <h2></h2> 63 <ol> 64 <li> 65 <a href="{@docRoot}resources/samples/ContactManager/index.html"> 66 </a> 67 68 </li> 69 <li> 70 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html"> 71 </a> 72 </li> 73 </ol> 74 <h2></h2> 75 <ol> 76 <li> 77 <a href="{@docRoot}guide/topics/providers/content-provider-basics.html"> 78 79 </a> 80 </li> 81 </ol> 82 </div> 83 </div> 84 <p> 85 Android 86 87 88 89 90 API 91 92 93 </p> 94 <p> 95 96 </p> 97 <ul> 98 <li> 99 100 </li> 101 <li> 102 103 </li> 104 <li> 105 106 </li> 107 <li> 108 109 110 </li> 111 </ul> 112 <p> 113 Android Android <a href="{@docRoot}guide/topics/providers/content-provider-basics.html"></a> 114 115 116 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html"></a> Google 117 118 119 120 </p> 121 <h2 id="InformationTypes"></h2> 122 <p> 123 Android 1 124 125 126 </p> 127 <img src="{@docRoot}images/providers/contacts_structure.png" alt="" height="364" id="figure1" /> 128 <p class="img-caption"> 129 <strong> 1.</strong> 130 </p> 131 <p> 132 URI 133 134 </p> 135 <dl> 136 <dt> 137 {@link android.provider.ContactsContract.Contacts} 138 </dt> 139 <dd> 140 141 </dd> 142 <dt> 143 {@link android.provider.ContactsContract.RawContacts} 144 </dt> 145 <dd> 146 147 </dd> 148 <dt> 149 {@link android.provider.ContactsContract.Data} 150 </dt> 151 <dd> 152 153 </dd> 154 </dl> 155 <p> 156 {@link android.provider.ContactsContract} 157 158 159 </p> 160 <h2 id="RawContactBasics"></h2> 161 <p> 162 163 164 165 166 167 </p> 168 <p> 169 170 {@link android.provider.ContactsContract.RawContacts} {@link android.provider.ContactsContract.Data} 171 172 {@link android.provider.ContactsContract.DataColumns#RAW_CONTACT_ID Data.RAW_CONTACT_ID} {@link android.provider.ContactsContract.RawContacts} {@code android.provider.BaseColumns#_ID RawContacts._ID} 173 174 175 </p> 176 <h3 id="RawContactsColumns"></h3> 177 <p> 178 {@link android.provider.ContactsContract.RawContacts} 1 179 180 </p> 181 <p class="table-caption" id="table1"> 182 <strong> 1.</strong> 183 </p> 184 <table> 185 <tr> 186 <th scope="col"></th> 187 <th scope="col"></th> 188 <th scope="col"></th> 189 </tr> 190 <tr> 191 <td> 192 {@link android.provider.ContactsContract.SyncColumns#ACCOUNT_NAME} 193 </td> 194 <td> 195 () 196 Google Gmail 197 198 {@link android.provider.ContactsContract.SyncColumns#ACCOUNT_TYPE} 199 200 </td> 201 <td> 202 203 204 </td> 205 </tr> 206 <tr> 207 <td> 208 {@link android.provider.ContactsContract.SyncColumns#ACCOUNT_TYPE} 209 </td> 210 <td> 211 Google <code>com.google</code> 212 213 214 215 </td> 216 <td> 217 218 219 </tr> 220 <tr> 221 <td> 222 {@link android.provider.ContactsContract.RawContactsColumns#DELETED} 223 </td> 224 <td> 225 226 </td> 227 <td> 228 229 230 231 </td> 232 </tr> 233 </table> 234 <h4></h4> 235 <p> 236 237 {@link android.provider.ContactsContract.RawContacts} 238 </p> 239 <ul> 240 <li> 241 242 {@link android.provider.ContactsContract.RawContacts} {@link android.provider.ContactsContract.Data} 243 {@link android.provider.ContactsContract.CommonDataKinds.StructuredName} 244 {@link android.provider.ContactsContract.Data} 245 246 </li> 247 <li> 248 <strong></strong> {@link android.accounts.AccountManager} 249 250 251 252 <p> 253 {@code com.example.dataservice} {@code becky.sharp (a] dataservice.example.com}({@code com.example.dataservice}) 254 ({@code becky.smart (a] dataservice.example.com}) 255 256 257 258 259 260 261 </li> 262 </ul> 263 <h3 id="RawContactsExample"></h3> 264 <p> 265 Emily Dickinson 266 267 </p> 268 <ul> 269 <li><code>emily.dickinson (a] gmail.com</code></li> 270 <li><code>emilyd (a] gmail.com</code></li> 271 <li>Twitter belle_of_amherst</li> 272 </ul> 273 <p> 274 <em></em><em></em> 275 276 </p> 277 <p> 278 Emily Dickinson 279 <code>emily.dickinson (a] gmail.com</code> Gmail[] Thomas Higginson 280 281 <code>emilyd (a] gmail.com</code> GmailThomas Higginson() 282 Twitter colonel_tom(Thomas Higginson Twitter ID) 283 284 </p> 285 <p> 286 287 </p> 288 <ol> 289 <li> 290 Thomas Higginson <code>emily.dickinson (a] gmail.com</code> 291 Google 292 </li> 293 <li> 294 Thomas Higginson <code>emilyd (a] gmail.com</code> 295 Google 296 297 298 </li> 299 <li> 300 Thomas Higginsonbelle_of_amherst Twitter 301 302 </li> 303 </ol> 304 <h2 id="DataBasics"></h2> 305 <p> 306 307 {@link android.provider.ContactsContract.Data} 308 <code>_ID</code> 309 {@code emilyd (a] gmail.com} "Thomas Higginson" (Thomas Higginson Google <code>emilyd (a] gmail.com</code> ) 310 <code>thigg (a] gmail.com</code> 311 <code>thomas.higginson (a] gmail.com</code> 312 313 314 315 </p> 316 <p> 317 {@link android.provider.ContactsContract.Data} 318 319 320 {@link android.provider.ContactsContract.Data} 321 () 322 323 324 </p> 325 <h3 id="DescriptiveColumns"></h3> 326 <p> 327 328 </p> 329 <dl> 330 <dt> 331 {@link android.provider.ContactsContract.Data#RAW_CONTACT_ID} 332 </dt> 333 <dd> 334 <code>_ID</code> 335 </dd> 336 <dt> 337 {@link android.provider.ContactsContract.Data#MIMETYPE} 338 </dt> 339 <dd> 340 MIME 341 {@link android.provider.ContactsContract.CommonDataKinds} MIME 342 MIME 343 344 </dd> 345 <dt> 346 {@link android.provider.ContactsContract.DataColumns#IS_PRIMARY} 347 </dt> 348 <dd> 349 350 {@link android.provider.ContactsContract.DataColumns#IS_PRIMARY} 351 []<strong></strong> {@link android.provider.ContactsContract.Data} {@link android.provider.ContactsContract.DataColumns#IS_PRIMARY} 352 353 354 355 356 </dd> 357 </dl> 358 <h3 id="GenericColumns"></h3> 359 <p> 360 15 ( <code>DATA1</code> 361 <code>DATA15</code>) 4 (<code>SYNC1</code> <code>SYNC4</code>) 362 363 364 365 </p> 366 <p> 367 <code>DATA1</code> 368 369 370 </p> 371 <p> 372 <code>DATA15</code> (BLOB) 373 374 </p> 375 <h3 id="TypeSpecificNames"></h3> 376 <p> 377 378 {@link android.provider.ContactsContract.CommonDataKinds} 379 380 381 382 </p> 383 <p> 384 {@link android.provider.ContactsContract.CommonDataKinds.Email} {@link android.provider.ContactsContract.Data} MIME {@link android.provider.ContactsContract.CommonDataKinds.Email#CONTENT_ITEM_TYPE 385 Email.CONTENT_ITEM_TYPE} 386 387 388 389 {@link android.provider.ContactsContract.CommonDataKinds.Email#ADDRESS} 390 391 {@link android.provider.ContactsContract.CommonDataKinds.Email#ADDRESS}data1 392 393 </p> 394 <p class="caution"> 395 <strong></strong> 396 {@link android.provider.ContactsContract.Data} MIME 397 398 MIME {@link android.provider.ContactsContract.CommonDataKinds.Email#CONTENT_ITEM_TYPE 399 Email.CONTENT_ITEM_TYPE} () <code>DATA1</code> 400 401 MIME 402 403 </p> 404 <p> 405 2 406 {@link android.provider.ContactsContract.Data} 407 408 </p> 409 <img src="{@docRoot}images/providers/data_columns.png" alt="How type-specific column names map to generic column names" height="311" id="figure2" /> 410 <p class="img-caption"> 411 <strong> 2.</strong> 412 </p> 413 <h3 id="ColumnMaps"></h3> 414 <p> 415 2 416 </p> 417 <p class="table-caption" id="table2"> 418 <strong> 2.</strong></p> 419 <table> 420 <tr> 421 <th scope="col"></th> 422 <th scope="col"></th> 423 <th scope="col"></th> 424 </tr> 425 <tr> 426 <td>{@link android.provider.ContactsContract.CommonDataKinds.StructuredName}</td> 427 <td> () </td> 428 <td></td> 429 </tr> 430 <tr> 431 <td>{@link android.provider.ContactsContract.CommonDataKinds.Photo}</td> 432 <td> () </td> 433 <td></td> 434 </tr> 435 <tr> 436 <td>{@link android.provider.ContactsContract.CommonDataKinds.Email}</td> 437 <td> () </td> 438 <td></td> 439 </tr> 440 <tr> 441 <td>{@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal}</td> 442 <td> () </td> 443 <td></td> 444 </tr> 445 <tr> 446 <td>{@link android.provider.ContactsContract.CommonDataKinds.GroupMembership}</td> 447 <td></td> 448 <td> 449 <a href="#Groups"></a> 450 451 </td> 452 </tr> 453 </table> 454 <h3 id="ContactBasics"></h3> 455 <p> 456 <strong></strong> 457 458 459 460 461 </p> 462 <p class="note"> 463 <strong></strong> 464 {@link android.content.ContentResolver#insert(Uri,ContentValues) insert()} {@link java.lang.UnsupportedOperationException} 465 466 467 </p> 468 <p> 469 470 471 472 <em></em> 473 474 475 </p> 476 <p> 477 {@link android.provider.ContactsContract.Contacts Contacts} 478 <code>_ID</code> 479 480 {@link android.provider.ContactsContract.RawContacts} <code>CONTACT_ID</code> () <code>_ID</code> 481 482 </p> 483 <p> 484 {@link android.provider.ContactsContract.Contacts} 485 {@code android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY} 486 {@code android.provider.BaseColumns#_ID} 487 488 489 {@code android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY} URI {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} 490 {@code android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY} 491 492 493 {@code android.provider.BaseColumns#_ID} 494 495 </p> 496 <p> 497 3 498 </p> 499 <img src="{@docRoot}images/providers/contacts_tables.png" alt="Contacts provider main tables" height="514" id="figure4" /> 500 <p class="img-caption"> 501 <strong> 3.</strong> 502 </p> 503 <h2 id="Sources"></h2> 504 <p> 505 <strong></strong> () 506 507 {@link android.content.ContentResolver} 508 509 510 </p> 511 <p> 512 Android 513 514 <a href="#RawContactsExample"></a> 515 516 517 </p> 518 <dl> 519 <dt> 520 521 </dt> 522 <dd> 523 524 Google <code>google.com</code> 525 526 {@link android.accounts.AccountManager} 527 </dd> 528 <dt> 529 530 </dt> 531 <dd> 532 Google Google 533 534 ID 535 </dd> 536 </dl> 537 <p> 538 Google 539 540 541 542 543 </p> 544 <p> 545 546 <a href="#SyncAdapters"></a> 547 548 </p> 549 <p> 550 4 551 552 </p> 553 <img src="{@docRoot}images/providers/ContactsDataFlow.png" alt="Flow of data about people" height="252" id="figure5" /> 554 <p class="img-caption"> 555 <strong> 4.</strong> 556 </p> 557 <h2 id="Permissions"></h2> 558 <p> 559 560 561 </p> 562 <dl> 563 <dt></dt> 564 <dd> 565 {@link android.Manifest.permission#READ_CONTACTS} 566 <code>AndroidManifest.xml</code> 567 <code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"> 568 <uses-permission></a></code> 569 <code><uses-permission android:name="android.permission.READ_CONTACTS"></code> 570 </dd> 571 <dt></dt> 572 <dd> 573 {@link android.Manifest.permission#WRITE_CONTACTS} 574 <code>AndroidManifest.xml</code> 575 <code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"> 576 <uses-permission></a></code> 577 <code><uses-permission android:name="android.permission.WRITE_CONTACTS"></code> 578 </dd> 579 </dl> 580 <p> 581 <a href="#UserProfile"></a> 582 583 584 </p> 585 <p> 586 587 588 589 590 </p> 591 <h2 id="UserProfile"></h2> 592 <p> 593 {@link android.provider.ContactsContract.Contacts} 594 <code>user</code> 595 596 597 {@link android.provider.ContactsContract.Profile} 598 599 </p> 600 <p> 601 602 {@link android.Manifest.permission#READ_CONTACTS} 603 {@link android.Manifest.permission#WRITE_CONTACTS} {@code android.Manifest.permission#READ_PROFILE} 604 {@code android.Manifest.permission#WRITE_PROFILE} 605 606 607 </p> 608 <p> 609 610 {@code android.Manifest.permission#READ_PROFILE} 611 612 613 </p> 614 <p> 615 {@link android.content.ContentResolver#query(Uri,String[], String, String[], String) 616 ContentResolver.query()} 617 URI 618 {@link android.provider.ContactsContract.Profile#CONTENT_URI} 619 URI URI 620 621 </p> 622 <pre> 623 // Sets the columns to retrieve for the user profile 624 mProjection = new String[] 625 { 626 Profile._ID, 627 Profile.DISPLAY_NAME_PRIMARY, 628 Profile.LOOKUP_KEY, 629 Profile.PHOTO_THUMBNAIL_URI 630 }; 631 632 // Retrieves the profile from the Contacts Provider 633 mProfileCursor = 634 getContentResolver().query( 635 Profile.CONTENT_URI, 636 mProjection , 637 null, 638 null, 639 null); 640 </pre> 641 <p class="note"> 642 <strong></strong> 643 {@link android.provider.ContactsContract.ContactsColumns#IS_USER_PROFILE} 644 1 645 646 </p> 647 <h2 id="ContactsProviderMetadata"></h2> 648 <p> 649 650 651 652 {@link android.provider.ContactsContract.Settings} 653 {@link android.provider.ContactsContract.SyncState} 654 655 </p> 656 <p class="table-caption" id="table3"> 657 <strong> 3.</strong></p> 658 <table> 659 <tr> 660 <th scope="col"></th> 661 <th scope="col"></th> 662 <th scope="col"></th> 663 <th scope="col"></th> 664 </tr> 665 <tr> 666 <td rowspan="2">{@link android.provider.ContactsContract.RawContacts}</td> 667 <td rowspan="2">{@link android.provider.ContactsContract.SyncColumns#DIRTY}</td> 668 <td>0</td> 669 <td rowspan="2"> 670 671 Android 672 673 <p> 674 {@link android.provider.ContactsContract#CALLER_IS_SYNCADAPTER} URI 675 676 (dirty) 677 678 679 </p> 680 </td> 681 </tr> 682 <tr> 683 <td>1</td> 684 </tr> 685 <tr> 686 <td>{@link android.provider.ContactsContract.RawContacts}</td> 687 <td>{@link android.provider.ContactsContract.SyncColumns#VERSION}</td> 688 <td></td> 689 <td> 690 691 692 </td> 693 </tr> 694 <tr> 695 <td>{@link android.provider.ContactsContract.Data}</td> 696 <td>{@link android.provider.ContactsContract.DataColumns#DATA_VERSION}</td> 697 <td></td> 698 <td> 699 700 701 </td> 702 </tr> 703 <tr> 704 <td>{@link android.provider.ContactsContract.RawContacts}</td> 705 <td>{@link android.provider.ContactsContract.SyncColumns#SOURCE_ID}</td> 706 <td> 707 () 708 709 </td> 710 <td> 711 ID 712 Android 713 714 {@link android.provider.ContactsContract.SyncColumns#SOURCE_ID} 715 716 <p> 717 ID <strong></strong> 718 719 </p> 720 <ul> 721 <li> 722 ID 723 724 <em></em> ID 725 {@code emily.dickinson (a] gmail.com} Thomas Higginson 726 {@code emilyd (a] gmail.com} Thomas Higginson ID 727 728 729 </li> 730 <li> 731 ID 732 ID 733 734 735 736 </li> 737 </ul> 738 </td> 739 </tr> 740 <tr> 741 <td rowspan="2">{@link android.provider.ContactsContract.Groups}</td> 742 <td rowspan="2">{@link android.provider.ContactsContract.GroupsColumns#GROUP_VISIBLE}</td> 743 <td>0Android UI </td> 744 <td> 745 746 747 </td> 748 </tr> 749 <tr> 750 <td>1 UI </td> 751 </tr> 752 <tr> 753 <td rowspan="2">{@link android.provider.ContactsContract.Settings}</td> 754 <td rowspan="2"> 755 {@link android.provider.ContactsContract.SettingsColumns#UNGROUPED_VISIBLE}</td> 756 <td> 757 0Android UI 758 759 </td> 760 <td rowspan="2"> 761 ({@link android.provider.ContactsContract.Data} 762 {@link android.provider.ContactsContract.CommonDataKinds.GroupMembership} ) 763 764 765 {@link android.provider.ContactsContract.Settings} 766 767 768 </td> 769 </tr> 770 <tr> 771 <td> 772 1 UI 773 774 </td> 775 776 </tr> 777 <tr> 778 <td>{@link android.provider.ContactsContract.SyncState}</td> 779 <td>()</td> 780 <td> 781 782 </td> 783 <td> 784 785 786 </td> 787 </tr> 788 </table> 789 <h2 id="Access"></h2> 790 <p> 791 792 793 </p> 794 <ul> 795 <li> 796 797 </li> 798 <li> 799 800 </li> 801 <li> 802 803 </li> 804 <li> 805 806 </li> 807 </ul> 808 <p> 809 <a href="#SyncAdapters"></a> 810 811 </p> 812 <h3 id="Entities"></h3> 813 <p> 814 815 816 {@link android.provider.ContactsContract.Contacts} 817 {@link android.provider.ContactsContract.RawContacts} 818 {@link android.provider.ContactsContract.RawContacts} 819 {@link android.provider.ContactsContract.CommonDataKinds.Email} 820 <strong></strong> 821 822 823 </p> 824 <p> 825 826 (projection) 827 {@link android.database.Cursor} 828 829 {@link android.provider.ContactsContract.Contacts.Entity} {@link android.provider.ContactsContract.CommonDataKinds.Email} {@link android.database.Cursor} {@link android.provider.ContactsContract.CommonDataKinds.Email} 830 831 832 833 </p> 834 <p> 835 ID ID 836 837 838 839 840 </p> 841 <p class="note"> 842 <strong></strong> 843 {@link java.lang.Exception} 844 845 </p> 846 <p> 847 Activity 848 Activity Activity ID Activity 849 850 Activity {@link android.provider.ContactsContract.Contacts.Entity} 851 852 853 </p> 854 <p> 855 Activity 856 </p> 857 <pre> 858 ... 859 /* 860 * Appends the entity path to the URI. In the case of the Contacts Provider, the 861 * expected URI is content://com.google.contacts/#/entity (# is the ID value). 862 */ 863 mContactUri = Uri.withAppendedPath( 864 mContactUri, 865 ContactsContract.Contacts.Entity.CONTENT_DIRECTORY); 866 867 // Initializes the loader identified by LOADER_ID. 868 getLoaderManager().initLoader( 869 LOADER_ID, // The identifier of the loader to initialize 870 null, // Arguments for the loader (in this case, none) 871 this); // The context of the activity 872 873 // Creates a new cursor adapter to attach to the list view 874 mCursorAdapter = new SimpleCursorAdapter( 875 this, // the context of the activity 876 R.layout.detail_list_item, // the view item containing the detail widgets 877 mCursor, // the backing cursor 878 mFromColumns, // the columns in the cursor that provide the data 879 mToViews, // the views in the view item that display the data 880 0); // flags 881 882 // Sets the ListView's backing adapter. 883 mRawContactList.setAdapter(mCursorAdapter); 884 ... 885 @Override 886 public Loader<Cursor> onCreateLoader(int id, Bundle args) { 887 888 /* 889 * Sets the columns to retrieve. 890 * RAW_CONTACT_ID is included to identify the raw contact associated with the data row. 891 * DATA1 contains the first column in the data row (usually the most important one). 892 * MIMETYPE indicates the type of data in the data row. 893 */ 894 String[] projection = 895 { 896 ContactsContract.Contacts.Entity.RAW_CONTACT_ID, 897 ContactsContract.Contacts.Entity.DATA1, 898 ContactsContract.Contacts.Entity.MIMETYPE 899 }; 900 901 /* 902 * Sorts the retrieved cursor by raw contact id, to keep all data rows for a single raw 903 * contact collated together. 904 */ 905 String sortOrder = 906 ContactsContract.Contacts.Entity.RAW_CONTACT_ID + 907 " ASC"; 908 909 /* 910 * Returns a new CursorLoader. The arguments are similar to 911 * ContentResolver.query(), except for the Context argument, which supplies the location of 912 * the ContentResolver to use. 913 */ 914 return new CursorLoader( 915 getApplicationContext(), // The activity's context 916 mContactUri, // The entity content URI for a single contact 917 projection, // The columns to retrieve 918 null, // Retrieve all the raw contacts and their data rows. 919 null, // 920 sortOrder); // Sort by the raw contact ID. 921 } 922 </pre> 923 <p> 924 {@link android.app.LoaderManager} {@link android.app.LoaderManager.LoaderCallbacks#onLoadFinished(Loader, D) 925 onLoadFinished()} 926 927 {@link android.database.Cursor} {@link android.database.Cursor} 928 929 </p> 930 <h3 id="Transactions"></h3> 931 <p> 932 933 {@link android.content.ContentProviderOperation} {@link java.util.ArrayList} 934 {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} 935 936 {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} 937 938 939 940 941 </p> 942 <p class="note"> 943 <strong></strong><em></em><a href="#Intents"></a> 944 945 946 947 </p> 948 <h4></h4> 949 <p> 950 951 <strong></strong> 952 953 954 {@link android.content.ContentProviderOperation} 955 {@link android.content.ContentProviderOperation#isYieldAllowed()} 956 <code>true</code> 957 {@link java.util.ArrayList} 958 959 960 </p> 961 <p> 962 963 {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} 964 965 966 967 968 </p> 969 <p> 970 971 972 973 974 975 </p> 976 <h4></h4> 977 <p> 978 979 {@link android.content.ContentProviderOperation} 980 {@code android.provider.BaseColumns#_ID} 981 {@link android.provider.ContactsContract.DataColumns#RAW_CONTACT_ID} 982 983 {@link android.content.ContentProviderOperation} 984 985 {@link android.content.ContentProviderOperation}{@link android.content.ContentProviderOperation.Builder} 986 {@link android.content.ContentProviderOperation.Builder#withValueBackReference(String, int) withValueBackReference()} 987 988 989 990 </p> 991 <p> 992 {@link android.content.ContentProviderOperation.Builder#withValueBackReference(String, int) withValueBackReference()} 993 994 </p> 995 <dl> 996 <dt> 997 <code>key</code> 998 </dt> 999 <dd> 1000 1001 1002 </dd> 1003 <dt> 1004 <code>previousResult</code> 1005 </dt> 1006 <dd> 1007 1008 {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} 1009 {@link android.content.ContentProviderResult} 0 1010 1011 <code>previousResult</code> <code>key</code> 1012 1013 1014 {@code android.provider.BaseColumns#_ID} {@link android.provider.ContactsContract.Data} 1015 1016 <p> 1017 1018 {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} 1019 {@link android.content.ContentProviderOperation} {@link java.util.ArrayList} 1020 <code>null</code> 1021 {@link android.content.ContentProviderOperation.Builder#withValueBackReference(String, int) withValueBackReference()} {@link java.lang.Exception} 1022 1023 1024 1025 1026 </p> 1027 </dd> 1028 </dl> 1029 <p> 1030 1031 <code>createContacEntry()</code> 1032 <code><a href="{@docRoot}resources/samples/ContactManager/index.html"> 1033 Contact Manager</a></code> 1034 <code>ContactAdder</code> 1035 1036 </p> 1037 <p> 1038 UI 1039 1040 </p> 1041 <pre> 1042 // Creates a contact entry from the current UI values, using the currently-selected account. 1043 protected void createContactEntry() { 1044 /* 1045 * Gets values from the UI 1046 */ 1047 String name = mContactNameEditText.getText().toString(); 1048 String phone = mContactPhoneEditText.getText().toString(); 1049 String email = mContactEmailEditText.getText().toString(); 1050 1051 int phoneType = mContactPhoneTypes.get( 1052 mContactPhoneTypeSpinner.getSelectedItemPosition()); 1053 1054 int emailType = mContactEmailTypes.get( 1055 mContactEmailTypeSpinner.getSelectedItemPosition()); 1056 </pre> 1057 <p> 1058 1059 {@link android.provider.ContactsContract.RawContacts} 1060 </p> 1061 <pre> 1062 /* 1063 * Prepares the batch operation for inserting a new raw contact and its data. Even if 1064 * the Contacts Provider does not have any data for this person, you can't add a Contact, 1065 * only a raw contact. The Contacts Provider will then add a Contact automatically. 1066 */ 1067 1068 // Creates a new array of ContentProviderOperation objects. 1069 ArrayList<ContentProviderOperation> ops = 1070 new ArrayList<ContentProviderOperation>(); 1071 1072 /* 1073 * Creates a new raw contact with its account type (server type) and account name 1074 * (user's account). Remember that the display name is not stored in this row, but in a 1075 * StructuredName data row. No other data is required. 1076 */ 1077 ContentProviderOperation.Builder op = 1078 ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI) 1079 .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, mSelectedAccount.getType()) 1080 .withValue(ContactsContract.RawContacts.ACCOUNT_NAME, mSelectedAccount.getName()); 1081 1082 // Builds the operation and adds it to the array of operations 1083 ops.add(op.build()); 1084 </pre> 1085 <p> 1086 1087 </p> 1088 <p> 1089 1090 {@link android.content.ContentProviderOperation.Builder#withValueBackReference(String, int) withValueBackReference()} 1091 {@link android.provider.ContactsContract.DataColumns#RAW_CONTACT_ID} 1092 {@link android.content.ContentProviderResult} ( {@code android.provider.BaseColumns#_ID} ) 1093 1094 1095 1096 {@link android.provider.ContactsContract.DataColumns#RAW_CONTACT_ID} {@link android.provider.ContactsContract.RawContacts} 1097 1098 </p> 1099 <p> 1100 {@link android.content.ContentProviderOperation.Builder} {@link android.content.ContentProviderOperation.Builder#withYieldAllowed(boolean) 1101 withYieldAllowed()} 1102 1103 </p> 1104 <pre> 1105 // Creates the display name for the new raw contact, as a StructuredName data row. 1106 op = 1107 ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) 1108 /* 1109 * withValueBackReference sets the value of the first argument to the value of 1110 * the ContentProviderResult indexed by the second argument. In this particular 1111 * call, the raw contact ID column of the StructuredName data row is set to the 1112 * value of the result returned by the first operation, which is the one that 1113 * actually adds the raw contact row. 1114 */ 1115 .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) 1116 1117 // Sets the data row's MIME type to StructuredName 1118 .withValue(ContactsContract.Data.MIMETYPE, 1119 ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) 1120 1121 // Sets the data row's display name to the name in the UI. 1122 .withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, name); 1123 1124 // Builds the operation and adds it to the array of operations 1125 ops.add(op.build()); 1126 1127 // Inserts the specified phone number and type as a Phone data row 1128 op = 1129 ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) 1130 /* 1131 * Sets the value of the raw contact id column to the new raw contact ID returned 1132 * by the first operation in the batch. 1133 */ 1134 .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) 1135 1136 // Sets the data row's MIME type to Phone 1137 .withValue(ContactsContract.Data.MIMETYPE, 1138 ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE) 1139 1140 // Sets the phone number and type 1141 .withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, phone) 1142 .withValue(ContactsContract.CommonDataKinds.Phone.TYPE, phoneType); 1143 1144 // Builds the operation and adds it to the array of operations 1145 ops.add(op.build()); 1146 1147 // Inserts the specified email and type as a Phone data row 1148 op = 1149 ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) 1150 /* 1151 * Sets the value of the raw contact id column to the new raw contact ID returned 1152 * by the first operation in the batch. 1153 */ 1154 .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) 1155 1156 // Sets the data row's MIME type to Email 1157 .withValue(ContactsContract.Data.MIMETYPE, 1158 ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE) 1159 1160 // Sets the email address and type 1161 .withValue(ContactsContract.CommonDataKinds.Email.ADDRESS, email) 1162 .withValue(ContactsContract.CommonDataKinds.Email.TYPE, emailType); 1163 1164 /* 1165 * Demonstrates a yield point. At the end of this insert, the batch operation's thread 1166 * will yield priority to other threads. Use after every set of operations that affect a 1167 * single contact, to avoid degrading performance. 1168 */ 1169 op.withYieldAllowed(true); 1170 1171 // Builds the operation and adds it to the array of operations 1172 ops.add(op.build()); 1173 </pre> 1174 <p> 1175 1176 {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} 1177 1178 </p> 1179 <pre> 1180 // Ask the Contacts Provider to create a new contact 1181 Log.d(TAG,"Selected account: " + mSelectedAccount.getName() + " (" + 1182 mSelectedAccount.getType() + ")"); 1183 Log.d(TAG,"Creating contact: " + name); 1184 1185 /* 1186 * Applies the array of ContentProviderOperation objects in batch. The results are 1187 * discarded. 1188 */ 1189 try { 1190 1191 getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); 1192 } catch (Exception e) { 1193 1194 // Display a warning 1195 Context ctx = getApplicationContext(); 1196 1197 CharSequence txt = getString(R.string.contactCreationFailure); 1198 int duration = Toast.LENGTH_SHORT; 1199 Toast toast = Toast.makeText(ctx, txt, duration); 1200 toast.show(); 1201 1202 // Log exception 1203 Log.e(TAG, "Exception encountered while inserting contact: " + e); 1204 } 1205 } 1206 </pre> 1207 <p> 1208 <strong></strong> 1209 1210 1211 1212 1213 </p> 1214 <p> 1215 1216 1217 1218 </p> 1219 <p> 1220 1221 {@link android.provider.ContactsContract.RawContacts} 1222 </p> 1223 <ol> 1224 <li> 1225 {@link android.provider.ContactsContract.SyncColumns#VERSION} 1226 1227 </li> 1228 <li> 1229 1230 {@link android.content.ContentProviderOperation#newAssertQuery(Uri)} {@link android.content.ContentProviderOperation.Builder} 1231 URI {@link android.provider.ContactsContract.RawContacts#CONTENT_URI 1232 RawContacts.CONTENT_URI} {@code android.provider.BaseColumns#_ID} 1233 1234 1235 </li> 1236 <li> 1237 {@link android.content.ContentProviderOperation.Builder} {@link android.content.ContentProviderOperation.Builder#withValue(String, Object) 1238 withValue()} {@link android.provider.ContactsContract.SyncColumns#VERSION} 1239 1240 1241 </li> 1242 <li> 1243 {@link android.content.ContentProviderOperation.Builder} {@link android.content.ContentProviderOperation.Builder#withExpectedCount(int) 1244 withExpectedCount()} 1245 1246 </li> 1247 <li> 1248 {@link android.content.ContentProviderOperation.Builder#build()} 1249 {@link android.content.ContentProviderOperation} 1250 {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} {@link java.util.ArrayList} 1251 1252 </li> 1253 <li> 1254 1255 </li> 1256 </ol> 1257 <p> 1258 {@link android.content.ContentProviderOperation} 1259 1260 1261 1262 </p> 1263 <p> 1264 {@link android.content.CursorLoader} 1265 {@link android.content.ContentProviderOperation} 1266 1267 </p> 1268 <pre> 1269 /* 1270 * The application uses CursorLoader to query the raw contacts table. The system calls this method 1271 * when the load is finished. 1272 */ 1273 public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { 1274 1275 // Gets the raw contact's _ID and VERSION values 1276 mRawContactID = cursor.getLong(cursor.getColumnIndex(BaseColumns._ID)); 1277 mVersion = cursor.getInt(cursor.getColumnIndex(SyncColumns.VERSION)); 1278 } 1279 1280 ... 1281 1282 // Sets up a Uri for the assert operation 1283 Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, mRawContactID); 1284 1285 // Creates a builder for the assert operation 1286 ContentProviderOperation.Builder assertOp = ContentProviderOperation.netAssertQuery(rawContactUri); 1287 1288 // Adds the assertions to the assert operation: checks the version and count of rows tested 1289 assertOp.withValue(SyncColumns.VERSION, mVersion); 1290 assertOp.withExpectedCount(1); 1291 1292 // Creates an ArrayList to hold the ContentProviderOperation objects 1293 ArrayList ops = new ArrayList<ContentProviderOperationg>; 1294 1295 ops.add(assertOp.build()); 1296 1297 // You would add the rest of your batch operations to "ops" here 1298 1299 ... 1300 1301 // Applies the batch. If the assert fails, an Exception is thrown 1302 try 1303 { 1304 ContentProviderResult[] results = 1305 getContentResolver().applyBatch(AUTHORITY, ops); 1306 1307 } catch (OperationApplicationException e) { 1308 1309 // Actions you want to take if the assert operation fails go here 1310 } 1311 </pre> 1312 <h3 id="Intents"></h3> 1313 <p> 1314 1315 UI 1316 1317 <ul> 1318 <li></li> 1319 <li></li> 1320 <li></li> 1321 <li></li> 1322 </ul> 1323 <p> 1324 1325 1326 </p> 1327 <p> 1328 UI 1329 1330 1331 1332 1333 </p> 1334 <p> 1335 <a href="{@docRoot}guide/topics/providers/content-provider-basics.html"></a> 1336 1337 4 MIME 1338 {@link android.content.Intent#putExtra(String, String) putExtra()} {@link android.provider.ContactsContract.Intents.Insert} 1339 1340 1341 1342 </p> 1343 <p class="table-caption" id="table4"> 1344 <strong> 4.</strong> 1345 </p> 1346 <table style="width:75%"> 1347 <tr> 1348 <th scope="col" style="width:10%"></th> 1349 <th scope="col" style="width:5%"></th> 1350 <th scope="col" style="width:10%"></th> 1351 <th scope="col" style="width:10%">MIME </th> 1352 <th scope="col" style="width:25%"></th> 1353 </tr> 1354 <tr> 1355 <td><strong></strong></td> 1356 <td>{@link android.content.Intent#ACTION_PICK}</td> 1357 <td> 1358 1359 <ul> 1360 <li> 1361 {@link android.provider.ContactsContract.Contacts#CONTENT_URI Contacts.CONTENT_URI} 1362 1363 </li> 1364 <li> 1365 {@link android.provider.ContactsContract.CommonDataKinds.Phone#CONTENT_URI Phone.CONTENT_URI} 1366 1367 </li> 1368 <li> 1369 {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#CONTENT_URI 1370 StructuredPostal.CONTENT_URI} 1371 1372 </li> 1373 <li> 1374 {@link android.provider.ContactsContract.CommonDataKinds.Email#CONTENT_URI Email.CONTENT_URI} 1375 1376 </li> 1377 </ul> 1378 </td> 1379 <td> 1380 1381 </td> 1382 <td> 1383 URI 1384 1385 <p> 1386 1387 {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult()} URI 1388 URI URI <code>LOOKUP_ID</code> 1389 1390 Activity URI 1391 <a href="{@docRoot}guide/topics/providers/content-provider-basics.html"></a> 1392 1393 1394 </p> 1395 </td> 1396 </tr> 1397 <tr> 1398 <td><strong></strong></td> 1399 <td>{@link android.provider.ContactsContract.Intents.Insert#ACTION Insert.ACTION}</td> 1400 <td></td> 1401 <td> 1402 {@link android.provider.ContactsContract.RawContacts#CONTENT_TYPE 1403 RawContacts.CONTENT_TYPE} MIME 1404 </td> 1405 <td> 1406 <strong></strong> 1407 1408 {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult()} URI {@link android.content.Intent} [] Activity 1409 {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult()} 1410 1411 1412 {@link android.content.Intent#getData()} 1413 </td> 1414 </tr> 1415 <tr> 1416 <td><strong></strong></td> 1417 <td>{@link android.content.Intent#ACTION_EDIT}</td> 1418 <td> 1419 {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} 1420 Activity 1421 1422 </td> 1423 <td> 1424 {@link android.provider.ContactsContract.Contacts#CONTENT_ITEM_TYPE 1425 Contacts.CONTENT_ITEM_TYPE}</td> 1426 <td> 1427 1428 []<strong></strong> Activity 1429 1430 </td> 1431 </tr> 1432 <tr> 1433 <td><strong></strong></td> 1434 <td>{@link android.content.Intent#ACTION_INSERT_OR_EDIT}</td> 1435 <td> 1436 1437 </td> 1438 <td> 1439 {@link android.provider.ContactsContract.Contacts#CONTENT_ITEM_TYPE} 1440 </td> 1441 <td> 1442 1443 1444 1445 1446 1447 1448 <p class="note"> 1449 <strong></strong> 1450 1451 1452 1453 1454 </p> 1455 </td> 1456 </tr> 1457 </table> 1458 <p> 1459 1460 1461 {@link android.content.ContentResolver#delete(Uri, String, String[]) ContentResolver.delete()} {@link android.content.ContentProviderOperation#newDelete(Uri) 1462 ContentProviderOperation.newDelete()} 1463 1464 </p> 1465 <p> 1466 1467 1468 </p> 1469 <pre> 1470 // Gets values from the UI 1471 String name = mContactNameEditText.getText().toString(); 1472 String phone = mContactPhoneEditText.getText().toString(); 1473 String email = mContactEmailEditText.getText().toString(); 1474 1475 String company = mCompanyName.getText().toString(); 1476 String jobtitle = mJobTitle.getText().toString(); 1477 1478 // Creates a new intent for sending to the device's contacts application 1479 Intent insertIntent = new Intent(ContactsContract.Intents.Insert.ACTION); 1480 1481 // Sets the MIME type to the one expected by the insertion activity 1482 insertIntent.setType(ContactsContract.RawContacts.CONTENT_TYPE); 1483 1484 // Sets the new contact name 1485 insertIntent.putExtra(ContactsContract.Intents.Insert.NAME, name); 1486 1487 // Sets the new company and job title 1488 insertIntent.putExtra(ContactsContract.Intents.Insert.COMPANY, company); 1489 insertIntent.putExtra(ContactsContract.Intents.Insert.JOB_TITLE, jobtitle); 1490 1491 /* 1492 * Demonstrates adding data rows as an array list associated with the DATA key 1493 */ 1494 1495 // Defines an array list to contain the ContentValues objects for each row 1496 ArrayList<ContentValues> contactData = new ArrayList<ContentValues>(); 1497 1498 1499 /* 1500 * Defines the raw contact row 1501 */ 1502 1503 // Sets up the row as a ContentValues object 1504 ContentValues rawContactRow = new ContentValues(); 1505 1506 // Adds the account type and name to the row 1507 rawContactRow.put(ContactsContract.RawContacts.ACCOUNT_TYPE, mSelectedAccount.getType()); 1508 rawContactRow.put(ContactsContract.RawContacts.ACCOUNT_NAME, mSelectedAccount.getName()); 1509 1510 // Adds the row to the array 1511 contactData.add(rawContactRow); 1512 1513 /* 1514 * Sets up the phone number data row 1515 */ 1516 1517 // Sets up the row as a ContentValues object 1518 ContentValues phoneRow = new ContentValues(); 1519 1520 // Specifies the MIME type for this data row (all data rows must be marked by their type) 1521 phoneRow.put( 1522 ContactsContract.Data.MIMETYPE, 1523 ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE 1524 ); 1525 1526 // Adds the phone number and its type to the row 1527 phoneRow.put(ContactsContract.CommonDataKinds.Phone.NUMBER, phone); 1528 1529 // Adds the row to the array 1530 contactData.add(phoneRow); 1531 1532 /* 1533 * Sets up the email data row 1534 */ 1535 1536 // Sets up the row as a ContentValues object 1537 ContentValues emailRow = new ContentValues(); 1538 1539 // Specifies the MIME type for this data row (all data rows must be marked by their type) 1540 emailRow.put( 1541 ContactsContract.Data.MIMETYPE, 1542 ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE 1543 ); 1544 1545 // Adds the email address and its type to the row 1546 emailRow.put(ContactsContract.CommonDataKinds.Email.ADDRESS, email); 1547 1548 // Adds the row to the array 1549 contactData.add(emailRow); 1550 1551 /* 1552 * Adds the array to the intent's extras. It must be a parcelable object in order to 1553 * travel between processes. The device's contacts app expects its key to be 1554 * Intents.Insert.DATA 1555 */ 1556 insertIntent.putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA, contactData); 1557 1558 // Send out the intent to start the device's contacts app in its add contact activity. 1559 startActivity(insertIntent); 1560 </pre> 1561 <h3 id="DataIntegrity"></h3> 1562 <p> 1563 1564 1565 1566 1567 </p> 1568 <dl> 1569 <dt> 1570 {@link android.provider.ContactsContract.RawContacts} {@link android.provider.ContactsContract.CommonDataKinds.StructuredName} 1571 1572 </dt> 1573 <dd> 1574 {@link android.provider.ContactsContract.Data} 1575 {@link android.provider.ContactsContract.CommonDataKinds.StructuredName} 1576 {@link android.provider.ContactsContract.RawContacts} 1577 1578 </dd> 1579 <dt> 1580 {@link android.provider.ContactsContract.Data} 1581 {@link android.provider.ContactsContract.RawContacts} 1582 </dt> 1583 <dd> 1584 1585 {@link android.provider.ContactsContract.RawContacts} {@link android.provider.ContactsContract.Data} 1586 1587 </dd> 1588 <dt> 1589 1590 </dt> 1591 <dd> 1592 1593 1594 1595 1596 </dd> 1597 <dt> 1598 {@link android.provider.ContactsContract} URIURI MIME 1599 {@link android.provider.ContactsContract.CommonDataKinds.CommonColumns#TYPE} 1600 1601 </dt> 1602 <dd> 1603 1604 1605 </dd> 1606 </dl> 1607 <h3 id="CustomData"></h3> 1608 <p> 1609 MIME {@link android.provider.ContactsContract.Data} 1610 1611 {@link android.provider.ContactsContract.DataColumns} 1612 1613 1614 1615 Activity 1616 1617 </p> 1618 <p> 1619 <code>contacts.xml</code> 1620 <code><ContactsAccountType></code> 1621 <code><ContactsDataKind></code> <a href="#SocialStreamDataKind"><code><ContactsDataKind> element</code></a> 1622 1623 </p> 1624 <p> 1625 MIME <a href="{@docRoot}guide/topics/providers/content-provider-creating.html"></a> 1626 1627 1628 </p> 1629 <h2 id="SyncAdapters"></h2> 1630 <p> 1631 <strong></strong> 1632 1633 1634 1635 1636 1637 </p> 1638 <p> 1639 Android 1640 1641 <ul> 1642 1643 <li> 1644 1645 </li> 1646 <li> 1647 1648 </li> 1649 <li> 1650 1651 </li> 1652 </ul> 1653 <p> 1654 1655 1656 1657 </p> 1658 <h3 id="SyncClassesFiles"></h3> 1659 <p> 1660 {@link android.content.AbstractThreadedSyncAdapter} Android 1661 1662 XML 1663 XML 1664 1665 1666 1667 1668 1669 </p> 1670 <p class="note"> 1671 <strong></strong> 1672 1673 Google <code>com.google</code> 1674 Google Google 1675 1676 1677 </p> 1678 <p> 1679 Android 1680 1681 1682 {@link android.accounts.AbstractAccountAuthenticator} 1683 1684 1685 <ol> 1686 <li> 1687 (<strong></strong>) 1688 1689 </li> 1690 <li> 1691 1692 </li> 1693 <li> 1694 1695 </li> 1696 </ol> 1697 <p> 1698 1699 1700 {@link android.accounts.AccountManager} authtoken OAuth2 authtoken 1701 1702 </p> 1703 <p> 1704 1705 Android 1706 </p> 1707 <h3 id="SyncAdapterImplementing"></h3> 1708 <p> 1709 Android 1710 1711 </p> 1712 <dl> 1713 <dt> 1714 {@link android.app.Service} 1715 1716 </dt> 1717 <dd> 1718 1719 {@link android.app.Service#onBind(Intent) onBind()} 1720 {@link android.os.IBinder} 1721 1722 <p> 1723 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html"></a> 1724 <code>com.example.android.samplesync.syncadapter.SyncService</code> 1725 1726 </p> 1727 </dd> 1728 <dt> 1729 1730 {@link android.content.AbstractThreadedSyncAdapter} 1731 </dt> 1732 <dd> 1733 1734 {@link android.content.AbstractThreadedSyncAdapter#onPerformSync( 1735 Account, Bundle, String, ContentProviderClient, SyncResult) 1736 onPerformSync()} 1737 1738 <p> 1739 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html"></a> 1740 <code>com.example.android.samplesync.syncadapter.SyncAdapter</code> 1741 1742 </p> 1743 </dd> 1744 <dt> 1745 {@link android.app.Application} 1746 </dt> 1747 <dd> 1748 1749 {@link android.app.Application#onCreate()} getter 1750 {@link android.app.Service#onBind(Intent) onBind()} 1751 1752 1753 </dd> 1754 <dt> 1755 <strong></strong> {@link android.app.Service} 1756 1757 </dt> 1758 <dd> 1759 {@link android.accounts.AccountManager} 1760 {@link android.app.Service#onCreate()} 1761 1762 {@link android.app.Service#onBind(Intent) onBind()} 1763 {@link android.os.IBinder} 1764 1765 1766 <p> 1767 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html"></a> 1768 <code>com.example.android.samplesync.authenticator.AuthenticationService</code> 1769 1770 </p> 1771 </dd> 1772 <dt> 1773 <strong></strong> 1774 {@link android.accounts.AbstractAccountAuthenticator} 1775 1776 </dt> 1777 <dd> 1778 {@link android.accounts.AccountManager} 1779 1780 1781 1782 <p> 1783 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html"></a> 1784 <code>com.example.android.samplesync.authenticator.Authenticator</code> 1785 1786 </p> 1787 </dd> 1788 <dt> 1789 XML 1790 </dt> 1791 <dd> 1792 1793 <code><<a href="{@docRoot}guide/topics/manifest/service-element.html">service</a>></code> 1794 1795 1796 <code><<a href="{@docRoot}guide/topics/manifest/meta-data-element.html">meta-data</a>></code> 1797 1798 1799 1800 <ul> 1801 <li> 1802 1803 <code><<a href="{@docRoot}guide/topics/manifest/meta-data-element.html">meta-data</a>></code> XML <code>res/xml/syncadapter.xml</code> 1804 1805 1806 URI 1807 1808 </li> 1809 <li> 1810 <strong></strong> 1811 <code><<a href="{@docRoot}guide/topics/manifest/meta-data-element.html">meta-data</a>></code> XML 1812 <code>res/xml/authenticator.xml</code> 1813 UI 1814 1815 1816 1817 1818 </li> 1819 </ul> 1820 </dd> 1821 </dl> 1822 <h2 id="SocialStream"></h2> 1823 <p> 1824 {@code android.provider.ContactsContract.StreamItems} 1825 {@code android.provider.ContactsContract.StreamItemPhotos} 1826 1827 1828 Android 1829 1830 </p> 1831 <h3 id="StreamText"></h3> 1832 <p> 1833 1834 {@code android.provider.ContactsContract.StreamItemsColumns#RAW_CONTACT_ID} 1835 <code>_ID</code> 1836 1837 </p> 1838 <p> 1839 1840 </p> 1841 <dl> 1842 <dt> 1843 {@code android.provider.ContactsContract.StreamItemsColumns#ACCOUNT_TYPE} 1844 </dt> 1845 <dd> 1846 <strong></strong> 1847 1848 </dd> 1849 <dt> 1850 {@code android.provider.ContactsContract.StreamItemsColumns#ACCOUNT_NAME} 1851 </dt> 1852 <dd> 1853 <strong></strong> 1854 1855 </dd> 1856 <dt> 1857 1858 </dt> 1859 <dd> 1860 <strong></strong> 1861 1862 <ul> 1863 <li> 1864 {@code android.provider.ContactsContract.StreamItemsColumns#CONTACT_ID} 1865 {@code android.provider.BaseColumns#_ID} 1866 1867 </li> 1868 <li> 1869 {@code android.provider.ContactsContract.StreamItemsColumns#CONTACT_LOOKUP_KEY} 1870 {@code android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY} 1871 1872 </li> 1873 <li> 1874 {@code android.provider.ContactsContract.StreamItemsColumns#RAW_CONTACT_ID} 1875 {@code android.provider.BaseColumns#_ID} 1876 1877 </li> 1878 </ul> 1879 </dd> 1880 <dt> 1881 {@code android.provider.ContactsContract.StreamItemsColumns#COMMENTS} 1882 </dt> 1883 <dd> 1884 1885 </dd> 1886 <dt> 1887 {@code android.provider.ContactsContract.StreamItemsColumns#TEXT} 1888 </dt> 1889 <dd> 1890 1891 1892 {@link android.text.Html#fromHtml(String) fromHtml()} 1893 1894 1895 </dd> 1896 <dt> 1897 {@code android.provider.ContactsContract.StreamItemsColumns#TIMESTAMP} 1898 </dt> 1899 <dd> 1900 1901 <em></em> 1902 1903 1904 </dd> 1905 </dl> 1906 <p> 1907 1908 {@code android.provider.ContactsContract.StreamItemsColumns#RES_ICON} 1909 {@code android.provider.ContactsContract.StreamItemsColumns#RES_LABEL} 1910 {@code android.provider.ContactsContract.StreamItemsColumns#RES_PACKAGE} 1911 1912 </p> 1913 <p> 1914 {@code android.provider.ContactsContract.StreamItems} 1915 {@code android.provider.ContactsContract.StreamItemsColumns#SYNC1} 1916 {@code android.provider.ContactsContract.StreamItemsColumns#SYNC4} 1917 1918 </p> 1919 <h3 id="StreamPhotos"></h3> 1920 <p> 1921 {@code android.provider.ContactsContract.StreamItemPhotos} 1922 1923 {@code android.provider.ContactsContract.StreamItemPhotosColumns#STREAM_ITEM_ID} 1924 {@code android.provider.ContactsContract.StreamItems} {@code android.provider.BaseColumns#_ID} 1925 1926 1927 </p> 1928 <dl> 1929 <dt> 1930 {@code android.provider.ContactsContract.StreamItemPhotos#PHOTO} (BLOB) 1931 </dt> 1932 <dd> 1933 1934 1935 1936 {@code android.provider.ContactsContract.StreamItemPhotosColumns#PHOTO_FILE_ID} 1937 {@code android.provider.ContactsContract.StreamItemPhotosColumns#PHOTO_URI} () 1938 1939 1940 1941 </dd> 1942 <dt> 1943 {@code android.provider.ContactsContract.StreamItemPhotosColumns#PHOTO_FILE_ID} 1944 </dt> 1945 <dd> 1946 1947 {@link android.provider.ContactsContract.DisplayPhoto#CONTENT_URI DisplayPhoto.CONTENT_URI} URI {@link android.content.ContentResolver#openAssetFileDescriptor(Uri, String) 1948 openAssetFileDescriptor()} 1949 1950 1951 </dd> 1952 <dt> 1953 {@code android.provider.ContactsContract.StreamItemPhotosColumns#PHOTO_URI} 1954 </dt> 1955 <dd> 1956 URI 1957 URI {@link android.content.ContentResolver#openAssetFileDescriptor(Uri, String) 1958 openAssetFileDescriptor()} 1959 </dd> 1960 </dl> 1961 <h3 id="SocialStreamTables"></h3> 1962 <p> 1963 1964 </p> 1965 <ul> 1966 <li> 1967 {@code android.Manifest.permission#READ_SOCIAL_STREAM} 1968 1969 {@code android.Manifest.permission#WRITE_SOCIAL_STREAM} 1970 1971 </li> 1972 <li> 1973 {@code android.provider.ContactsContract.StreamItems} 1974 1975 {@code android.provider.ContactsContract.StreamItemsColumns#TIMESTAMP} 1976 1977 URI 1978 {@code android.provider.ContactsContract.StreamItems#CONTENT_LIMIT_URI} 1979 URI <code>null</code> 1980 Cursor 1981 {@code android.provider.ContactsContract.StreamItems#MAX_ITEMS} 1982 1983 </li> 1984 </ul> 1985 1986 <p> 1987 {@code android.provider.ContactsContract.StreamItems.StreamItemPhotos} {@code android.provider.ContactsContract.StreamItemPhotos} 1988 1989 1990 </p> 1991 <h3 id="SocialStreamInteraction"></h3> 1992 <p> 1993 1994 1995 1996 </p> 1997 <ul> 1998 <li> 1999 Activity {@code android.provider.ContactsContract.StreamItems} 2000 {@code android.provider.ContactsContract.StreamItemPhotos} 2001 2002 2003 </li> 2004 <li> 2005 2006 2007 2008 </li> 2009 <li> 2010 <em></em> 2011 2012 2013 2014 </li> 2015 <li> 2016 2017 Activity XML 2018 2019 2020 2021 </li> 2022 </ul> 2023 <p> 2024 2025 <a href="#SyncAdapters"></a> 2026 2027 2028 </p> 2029 <h4></h4> 2030 <p> 2031 2032 2033 </p> 2034 <ol> 2035 <li> 2036 <code>res/xml/</code> <code>contacts.xml</code> 2037 2038 </li> 2039 <li> 2040 2041 <code><ContactsAccountType xmlns:android="http://schemas.android.com/apk/res/android"></code> 2042 2043 </li> 2044 <li> 2045 2046 <code>viewContactNotifyService="<em>serviceclass</em>"</code> 2047 <code><em>serviceclass</em></code> 2048 2049 {@link android.app.IntentService} 2050 2051 URI 2052 2053 2054 </li> 2055 </ol> 2056 <p> 2057 () Activity 2058 </p> 2059 <ol> 2060 <li> 2061 <code>res/xml/</code> <code>contacts.xml</code> 2062 2063 </li> 2064 <li> 2065 2066 <code><ContactsAccountType xmlns:android="http://schemas.android.com/apk/res/android"></code> 2067 2068 </li> 2069 <li> 2070 Activity Activity 2071 <code>viewStreamItemActivity="<em>activityclass</em>"</code> 2072 <code><em>activityclass</em></code> Activity Activity 2073 2074 2075 </li> 2076 <li> 2077 Activity 2078 <code>viewStreamItemPhotoActivity="<em>activityclass</em>"</code> 2079 <code><em>activityclass</em></code> Activity Activity 2080 2081 2082 </li> 2083 </ol> 2084 <p> 2085 <code><ContactsAccountType></code> <a href="#SocialStreamAcctType"><ContactsAccountType> </a> 2086 2087 </p> 2088 <p> 2089 URI 2090 Activity 2091 </p> 2092 <h4></h4> 2093 <p> 2094 2095 Activity 2096 2097 </p> 2098 <ol> 2099 <li> 2100 <code>res/xml/</code> <code>contacts.xml</code> 2101 2102 </li> 2103 <li> 2104 <code><ContactsAccountType xmlns:android="http://schemas.android.com/apk/res/android"></code> 2105 2106 2107 </li> 2108 <li> 2109 2110 <ul> 2111 <li><code>inviteContactActivity="<em>activityclass</em>"</code></li> 2112 <li> 2113 <code>inviteContactActionLabel="@string/<em>invite_action_label</em>"</code> 2114 </li> 2115 </ul> 2116 <code><em>activityclass</em></code> Activity Activity 2117 <code><em>invite_action_label</em></code> []<strong></strong> 2118 2119 2120 </li> 2121 </ol> 2122 <p class="note"> 2123 <strong></strong><code>ContactsSource</code> 2124 <code>ContactsAccountType</code> 2125 </p> 2126 <h3 id="ContactsFile">contacts.xml </h3> 2127 <p> 2128 <code>contacts.xml</code> XML () 2129 2130 2131 </p> 2132 <h4 id="SocialStreamAcctType"><ContactsAccountType> </h4> 2133 <p> 2134 <code><ContactsAccountType></code> 2135 2136 </p> 2137 <pre> 2138 <ContactsAccountType 2139 xmlns:android="http://schemas.android.com/apk/res/android" 2140 inviteContactActivity="<em>activity_name</em>" 2141 inviteContactActionLabel="<em>invite_command_text</em>" 2142 viewContactNotifyService="<em>view_notify_service</em>" 2143 viewGroupActivity="<em>group_view_activity</em>" 2144 viewGroupActionLabel="<em>group_action_text</em>" 2145 viewStreamItemActivity="<em>viewstream_activity_name</em>" 2146 viewStreamItemPhotoActivity="<em>viewphotostream_activity_name</em>"> 2147 </pre> 2148 <p> 2149 <strong></strong> 2150 </p> 2151 <p> 2152 <code>res/xml/contacts.xml</code> 2153 </p> 2154 <p> 2155 <strong></strong> 2156 </p> 2157 <p> 2158 <strong><code><ContactsDataKind></code></strong> 2159 </p> 2160 <p> 2161 <strong></strong> 2162 </p> 2163 <p> 2164 Android UI 2165 2166 2167 </p> 2168 <p> 2169 <code><ContactsAccountType></code> <code>android:</code> 2170 2171 </p> 2172 <p> 2173 <strong></strong> 2174 </p> 2175 <dl> 2176 <dt>{@code inviteContactActivity}</dt> 2177 <dd> 2178 []<strong></strong> Activity 2179 2180 2181 </dd> 2182 <dt>{@code inviteContactActionLabel}</dt> 2183 <dd> 2184 []<strong></strong> 2185 {@code inviteContactActivity} Activity 2186 2187 2188 </dd> 2189 <dt>{@code viewContactNotifyService}</dt> 2190 <dd> 2191 2192 2193 2194 2195 2196 <a href="#SocialStreamInteraction"></a> 2197 2198 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html">SampleSyncAdapter</a> <code>NotifierService.java</code> 2199 2200 2201 </dd> 2202 <dt>{@code viewGroupActivity}</dt> 2203 <dd> 2204 Activity 2205 Activity UI 2206 2207 </dd> 2208 <dt>{@code viewGroupActionLabel}</dt> 2209 <dd> 2210 UI 2211 2212 <p> 2213 Google+ Google+ Google+ []<strong></strong> 2214 2215 Google+ 2216 Google+ Google+ 2217 {@code viewGroupActivity} Google+ 2218 {@code viewGroupActionLabel} 2219 2220 2221 </p> 2222 <p> 2223 2224 </p> 2225 </dd> 2226 <dt>{@code viewStreamItemActivity}</dt> 2227 <dd> 2228 Activity 2229 2230 </dd> 2231 <dt>{@code viewStreamItemPhotoActivity}</dt> 2232 <dd> 2233 Activity 2234 2235 2236 </dd> 2237 </dl> 2238 <h4 id="SocialStreamDataKind"><ContactsDataKind> </h4> 2239 <p> 2240 <code><ContactsDataKind></code> UI 2241 2242 </p> 2243 <pre> 2244 <ContactsDataKind 2245 android:mimeType="<em>MIMEtype</em>" 2246 android:icon="<em>icon_resources</em>" 2247 android:summaryColumn="<em>column_name</em>" 2248 android:detailColumn="<em>column_name</em>"> 2249 </pre> 2250 <p> 2251 <strong></strong> 2252 </p> 2253 <code><ContactsAccountType></code> 2254 <p> 2255 <strong></strong> 2256 </p> 2257 <p> 2258 2259 <code><ContactsAccountType></code> <code><ContactsDataKind></code> {@link android.provider.ContactsContract.Data} 2260 2261 MIME 2262 <code><ContactsDataKind></code> 2263 2264 </p> 2265 <p> 2266 <strong></strong> 2267 </p> 2268 <dl> 2269 <dt>{@code android:mimeType}</dt> 2270 <dd> 2271 2272 {@link android.provider.ContactsContract.Data} MIME 2273 <code>vnd.android.cursor.item/vnd.example.locationstatus</code> 2274 MIME 2275 </dd> 2276 <dt>{@code android:icon}</dt> 2277 <dd> 2278 Android 2279 <a href="{@docRoot}guide/topics/resources/drawable-resource.html"></a> 2280 2281 2282 </dd> 2283 <dt>{@code android:summaryColumn}</dt> 2284 <dd> 2285 2286 2287 2288 <a href="#detailColumn">android:detailColumn</a> 2289 </dd> 2290 <dt>{@code android:detailColumn}</dt> 2291 <dd> 2292 2293 2294 {@code android:summaryColumn} 2295 </dd> 2296 </dl> 2297 <h2 id="AdditionalFeatures"></h2> 2298 <p> 2299 2300 2301 </p> 2302 <ul> 2303 <li></li> 2304 <li></li> 2305 </ul> 2306 <h3 id="Groups"></h3> 2307 <p> 2308 <strong></strong> 2309 2310 2311 {@link android.provider.ContactsContract.Groups} 2312 2313 {@link android.provider.ContactsContract.CommonDataKinds.GroupMembership} MIME {@link android.provider.ContactsContract.Data} 2314 2315 2316 </p> 2317 <p> 2318 2319 2320 {@link android.provider.ContactsContract.Settings} 2321 2322 {@link android.provider.ContactsContract.SettingsColumns#UNGROUPED_VISIBLE 2323 Settings.UNGROUPED_VISIBLE} 1 2324 2325 2326 </p> 2327 <h3 id="Photos"></h3> 2328 <p> 2329 {@link android.provider.ContactsContract.Data} MIME {@link android.provider.ContactsContract.CommonDataKinds.Photo#CONTENT_ITEM_TYPE 2330 Photo.CONTENT_ITEM_TYPE} 2331 2332 {@link android.provider.ContactsContract.RawContactsColumns#CONTACT_ID} 2333 {@code android.provider.BaseColumns#_ID} 2334 {@link android.provider.ContactsContract.Contacts.Photo} 2335 {@link android.provider.ContactsContract.Contacts} 2336 2337 {@link android.provider.ContactsContract.RawContacts.DisplayPhoto} {@link android.provider.ContactsContract.RawContacts} 2338 2339 2340 </p> 2341 <p> 2342 {@link android.provider.ContactsContract.Contacts.Photo} 2343 {@link android.provider.ContactsContract.RawContacts.DisplayPhoto} 2344 2345 {@link android.provider.ContactsContract.Data} 2346 {@code android.provider.BaseColumns#_ID}{@link android.provider.ContactsContract.CommonDataKinds.Photo#CONTENT_ITEM_TYPE 2347 Photo.CONTENT_ITEM_TYPE} {@link android.provider.ContactsContract.Data#IS_PRIMARY} 2348 2349 2350 2351 </p> 2352 <p> 2353 2354 {@code android.provider.ContactsContract.StreamItemPhotos} <a href="#StreamPhotos"></a> 2355 2356 </p> 2357