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"> Contact Manager </a> 66 67 68 </li> 69 <li> 70 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html"> </a> 71 72 </li> 73 </ol> 74 <h2></h2> 75 <ol> 76 <li> 77 <a href="{@docRoot}guide/topics/providers/content-provider-basics.html"> </a> 78 79 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 3 1 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 3 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 1 163 1 164 165 166 167 </p> 168 <p> 169 {@link android.provider.ContactsContract.RawContacts} 170 {@link android.provider.ContactsContract.Data} 1 171 {@link android.provider.ContactsContract.DataColumns#RAW_CONTACT_ID Data.RAW_CONTACT_ID} {@link android.provider.ContactsContract.RawContacts} {@code android.provider.BaseColumns#_ID RawContacts._ID} 172 173 174 175 </p> 176 <h3 id="RawContactsColumns"></h3> 177 <p> 178 1 {@link android.provider.ContactsContract.RawContacts} 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 {@link android.provider.ContactsContract.SyncColumns#ACCOUNT_TYPE} 198 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 ID 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 {@link android.provider.ContactsContract.RawContacts} 237 238 </p> 239 <ul> 240 <li> 241 {@link android.provider.ContactsContract.RawContacts} 242 {@link android.provider.ContactsContract.Data} {@link android.provider.ContactsContract.CommonDataKinds.StructuredName} 243 244 {@link android.provider.ContactsContract.Data} 1 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}{@code becky.smart (a] dataservice.example.com} 254 255 256 257 258 259 260 261 </li> 262 </ul> 263 <h3 id="RawContactsExample"></h3> 264 <p> 265 Emily Dickinson 3 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>] 3 [<em></em>] 275 276 </p> 277 <p> 278 Emily Dickinson Gmail <code>emily.dickinson (a] gmail.com</code> [] Thomas Higginson 279 280 Gmail <code>emilyd (a] gmail.com</code> Thomas Higginson 281 282 Twitter colonel_tomThomas Higginson Twitter ID 283 284 </p> 285 <p> 286 3 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 <code>_ID</code> {@link android.provider.ContactsContract.Data} 307 308 1 309 {@code emilyd (a] gmail.com} Thomas HigginsonGoogle <code>emilyd (a] gmail.com</code> Thomas Higginson <code>thigg (a] gmail.com</code> <code>thomas.higginson (a] gmail.com</code> 2 310 311 312 313 314 315 </p> 316 <p> 317 {@link android.provider.ContactsContract.Data} 318 319 {@link android.provider.ContactsContract.Data} 320 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 {@link android.provider.ContactsContract.CommonDataKinds} MIME 341 342 MIME 343 344 </dd> 345 <dt> 346 {@link android.provider.ContactsContract.DataColumns#IS_PRIMARY} 347 </dt> 348 <dd> 349 1 {@link android.provider.ContactsContract.DataColumns#IS_PRIMARY} 350 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 <code>DATA1</code> <code>DATA15</code> 15 <code>SYNC1</code> <code>SYNC4</code> 4 361 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 {@link android.provider.ContactsContract.CommonDataKinds} 378 379 380 381 382 </p> 383 <p> 384 {@link android.provider.ContactsContract.CommonDataKinds.Email} MIME {@link android.provider.ContactsContract.CommonDataKinds.Email#CONTENT_ITEM_TYPE Email.CONTENT_ITEM_TYPE} {@link android.provider.ContactsContract.Data} 385 386 387 388 {@link android.provider.ContactsContract.CommonDataKinds.Email#ADDRESS} 389 390 {@link android.provider.ContactsContract.CommonDataKinds.Email#ADDRESS} data1 391 392 393 </p> 394 <p class="caution"> 395 <strong>:</strong> MIME {@link android.provider.ContactsContract.Data} 396 397 398 MIME {@link android.provider.ContactsContract.CommonDataKinds.Email#CONTENT_ITEM_TYPE Email.CONTENT_ITEM_TYPE} <code>DATA1</code> 399 400 401 MIME 402 403 </p> 404 <p> 405 2 {@link android.provider.ContactsContract.Data} 406 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>1 1 </td> 429 </tr> 430 <tr> 431 <td>{@link android.provider.ContactsContract.CommonDataKinds.Photo}</td> 432 <td></td> 433 <td>1 1 </td> 434 </tr> 435 <tr> 436 <td>{@link android.provider.ContactsContract.CommonDataKinds.Email}</td> 437 <td></td> 438 <td>1 </td> 439 </tr> 440 <tr> 441 <td>{@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal}</td> 442 <td></td> 443 <td>1 </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 1 <strong></strong> 457 1 458 459 460 461 </p> 462 <p class="note"> 463 <strong>:</strong> {@link android.content.ContentResolver#insert(Uri,ContentValues) insert()} {@link java.lang.UnsupportedOperationException} 464 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} <code>_ID</code> 478 479 {@link android.provider.ContactsContract.RawContacts} <code>CONTACT_ID</code> <code>_ID</code> 480 481 482 </p> 483 <p> 484 {@link android.provider.ContactsContract.Contacts} {@code android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY} 485 486 {@code android.provider.BaseColumns#_ID} 487 488 URI {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} {@code android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY} {@code android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY} 489 490 491 492 493 {@code android.provider.BaseColumns#_ID} 494 495 </p> 496 <p> 497 3 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> ContactsRawContactsData 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 1 514 <a href="#RawContactsExample"></a> 515 516 517 </p> 518 <dl> 519 <dt> 520 521 </dt> 522 <dd> 523 524 Google Contacts 1 <code>google.com</code> 525 {@link android.accounts.AccountManager} 526 527 </dd> 528 <dt> 529 530 </dt> 531 <dd> 532 Google Contacts Google 533 534 1 ID 535 </dd> 536 </dl> 537 <p> 538 1 Google Contacts 539 540 541 2 542 543 </p> 544 <p> 545 546 <a href="#SyncAdapters"></a> 547 548 </p> 549 <p> 550 4 551 2 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>1 </dt> 564 <dd> 565 {@link android.Manifest.permission#READ_CONTACTS}<code>AndroidManifest.xml</code> <code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"> 566 <uses-permission></a></code> <code><uses-permission android:name="android.permission.READ_CONTACTS"></code> 567 568 569 570 </dd> 571 <dt>1 </dt> 572 <dd> 573 {@link android.Manifest.permission#WRITE_CONTACTS}<code>AndroidManifest.xml</code> <code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"> 574 <uses-permission></a></code> <code><uses-permission android:name="android.permission.WRITE_CONTACTS"></code> 575 576 577 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} 1 594 <code>user</code> 595 596 597 {@link android.provider.ContactsContract.Profile} 598 599 </p> 600 <p> 601 {@link android.Manifest.permission#READ_CONTACTS} {@link android.Manifest.permission#WRITE_CONTACTS} {@code android.Manifest.permission#READ_PROFILE} {@code android.Manifest.permission#WRITE_PROFILE} 602 603 604 605 606 607 </p> 608 <p> 609 {@code android.Manifest.permission#READ_PROFILE} 610 611 612 613 </p> 614 <p> 615 {@link android.content.ContentResolver#query(Uri,String[], String, String[], String) ContentResolver.query()} 616 617 URI {@link android.provider.ContactsContract.Profile#CONTENT_URI} 618 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> 1 {@link android.provider.ContactsContract.ContactsColumns#IS_USER_PROFILE} 643 644 1 645 646 </p> 647 <h2 id="ContactsProviderMetadata"></h2> 648 <p> 649 650 RawContactsDataContacts {@link android.provider.ContactsContract.Settings} {@link android.provider.ContactsContract.SyncState} 651 652 653 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 URI {@link android.provider.ContactsContract#CALLER_IS_SYNCADAPTER} 675 676 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 {@link android.provider.ContactsContract.SyncColumns#SOURCE_ID} 714 715 716 <p> 717 ID <strong></strong> 718 719 </p> 720 <ul> 721 <li> 722 Unique: ID 723 724 <em></em> 2 ID 725 {@code emily.dickinson (a] gmail.com} Thomas Higginson {@code emilyd (a] gmail.com} Thomas Higginson ID 726 727 728 729 </li> 730 <li> 731 Stable: 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>0 - Android UI </td> 744 <td> 745 746 747 </td> 748 </tr> 749 <tr> 750 <td>1 - Android 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 0 - Android UI 758 759 </td> 760 <td rowspan="2"> 761 {@link android.provider.ContactsContract.Data} 1 {@link android.provider.ContactsContract.CommonDataKinds.GroupMembership} 762 763 764 765 {@link android.provider.ContactsContract.Settings} 766 767 1 768 </td> 769 </tr> 770 <tr> 771 <td> 772 0 - Android 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 {@link android.provider.ContactsContract.Contacts} 1 {@link android.provider.ContactsContract.RawContacts} {@link android.provider.ContactsContract.RawContacts} 1 {@link android.provider.ContactsContract.CommonDataKinds.Email} 816 817 818 819 820 <strong></strong> 821 822 823 </p> 824 <p> 825 1 826 827 {@link android.database.Cursor} 1 828 {@link android.provider.ContactsContract.CommonDataKinds.Email} {@link android.provider.ContactsContract.Contacts.Entity} {@link android.provider.ContactsContract.CommonDataKinds.Email} 1 {@link android.database.Cursor} 829 830 831 832 833 </p> 834 <p> 835 ID ID 1 836 837 838 839 840 </p> 841 <p class="note"> 842 <strong>:</strong> 843 {@link java.lang.Exception} 844 845 </p> 846 <p> 847 2 848 1 ID 849 850 {@link android.provider.ContactsContract.Contacts.Entity} 851 852 853 </p> 854 <p> 855 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) onLoadFinished()} 925 926 1 {@link android.database.Cursor} 927 {@link android.database.Cursor} 928 929 </p> 930 <h3 id="Transactions"></h3> 931 <p> 932 {@link android.content.ContentProviderOperation} {@link java.util.ArrayList} {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} 933 934 935 1 1 {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} 936 937 938 939 940 941 </p> 942 <p class="note"> 943 <strong>:</strong> <em>1 </em><a href="#Intents"></a> 944 945 946 947 </p> 948 <h4></h4> 949 <p> 950 951 1 <strong></strong> 952 953 954 {@link android.content.ContentProviderOperation#isYieldAllowed()} <code>true</code> {@link android.content.ContentProviderOperation} 955 956 957 {@link java.util.ArrayList} 958 959 960 </p> 961 <p> 962 {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} 1 963 1 964 965 1 1 966 967 968 </p> 969 <p> 970 2 1 971 972 973 974 975 </p> 976 <h4></h4> 977 <p> 978 1 {@link android.content.ContentProviderOperation} {@code android.provider.BaseColumns#_ID} {@link android.provider.ContactsContract.DataColumns#RAW_CONTACT_ID} 979 980 981 982 {@link android.content.ContentProviderOperation} {@link android.content.ContentProviderOperation} 983 984 985 {@link android.content.ContentProviderOperation.Builder} {@link android.content.ContentProviderOperation.Builder#withValueBackReference(String, int) withValueBackReference()} 986 987 988 989 990 </p> 991 <p> 992 {@link android.content.ContentProviderOperation.Builder#withValueBackReference(String, int) withValueBackReference()} 2 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 {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} {@link android.content.ContentProviderResult} 0 1008 1009 1010 1011 <code>previousResult</code> 1 <code>key</code> 1012 1013 {@code android.provider.BaseColumns#_ID} {@link android.provider.ContactsContract.Data} 1014 1015 1016 <p> 1017 {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} {@link android.content.ContentProviderOperation} {@link java.util.ArrayList} 1018 1019 1020 <code>null</code> {@link android.content.ContentProviderOperation.Builder#withValueBackReference(String, int) withValueBackReference()} {@link java.lang.Exception} 1021 1022 1023 1024 1025 1026 </p> 1027 </dd> 1028 </dl> 1029 <p> 1030 1031 <code><a href="{@docRoot}resources/samples/ContactManager/index.html"> 1032 Contact Manager</a></code> <code>ContactAdder</code> <code>createContacEntry()</code> 1033 1034 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 {@link android.provider.ContactsContract.RawContacts} 1059 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 {@link android.content.ContentProviderOperation.Builder#withValueBackReference(String, int) withValueBackReference()} {@link android.provider.ContactsContract.DataColumns#RAW_CONTACT_ID} 1090 1091 1092 {@link android.content.ContentProviderResult} {@code android.provider.BaseColumns#_ID} 1093 1094 1095 {@link android.provider.ContactsContract.DataColumns#RAW_CONTACT_ID} {@link android.provider.ContactsContract.RawContacts} 1096 1097 1098 </p> 1099 <p> 1100 {@link android.content.ContentProviderOperation.Builder} {@link android.content.ContentProviderOperation.Builder#withYieldAllowed(boolean) withYieldAllowed()} 1101 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 {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} 1176 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 1 1216 1217 1218 </p> 1219 <p> 1220 {@link android.provider.ContactsContract.RawContacts} 1 1221 1222 </p> 1223 <ol> 1224 <li> 1225 {@link android.provider.ContactsContract.SyncColumns#VERSION} 1226 1227 </li> 1228 <li> 1229 {@link android.content.ContentProviderOperation.Builder} {@link android.content.ContentProviderOperation#newAssertQuery(Uri)} 1230 1231 URI {@code android.provider.BaseColumns#_ID} {@link android.provider.ContactsContract.RawContacts#CONTENT_URI RawContacts.CONTENT_URI} 1232 1233 1234 1235 </li> 1236 <li> 1237 {@link android.content.ContentProviderOperation.Builder} {@link android.content.ContentProviderOperation.Builder#withValue(String, Object) withValue()} {@link android.provider.ContactsContract.SyncColumns#VERSION} 1238 1239 1240 1241 </li> 1242 <li> 1243 {@link android.content.ContentProviderOperation.Builder} {@link android.content.ContentProviderOperation.Builder#withExpectedCount(int) withExpectedCount()} 1 1244 1245 1246 </li> 1247 <li> 1248 {@link android.content.ContentProviderOperation.Builder#build()} {@link android.content.ContentProviderOperation} {@link android.content.ContentResolver#applyBatch(String, ArrayList) applyBatch()} {@link java.util.ArrayList} 1249 1250 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} 1 {@link android.content.ContentProviderOperation} 1265 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 {@link android.content.Intent#putExtra(String, String) putExtra()} {@link android.provider.ContactsContract.Intents.Insert} 1338 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 StructuredPostal.CONTENT_URI} 1370 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 {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult()} URI 1387 1388 URI URI <code>LOOKUP_ID</code> 1389 1390 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 RawContacts.CONTENT_TYPE} MIME 1403 1404 </td> 1405 <td> 1406 [<strong></strong>] 1407 {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult()} URI {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult()} {@link android.content.Intent} data 1408 1409 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 1421 1422 </td> 1423 <td> 1424 {@link android.provider.ContactsContract.Contacts#CONTENT_ITEM_TYPE Contacts.CONTENT_ITEM_TYPE}1 1425 </td> 1426 <td> 1427 1428 [<strong></strong>] 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 {@link android.content.ContentResolver#delete(Uri, String, String[]) ContentResolver.delete()} {@link android.content.ContentProviderOperation#newDelete(Uri) ContentProviderOperation.newDelete()} 1461 1462 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.CommonDataKinds.StructuredName} {@link android.provider.ContactsContract.RawContacts} 1571 1572 </dt> 1573 <dd> 1574 {@link android.provider.ContactsContract.Data} {@link android.provider.ContactsContract.CommonDataKinds.StructuredName} {@link android.provider.ContactsContract.RawContacts} 1575 1576 1577 1578 </dd> 1579 <dt> 1580 {@link android.provider.ContactsContract.Data} {@link android.provider.ContactsContract.RawContacts} 1581 1582 </dt> 1583 <dd> 1584 {@link android.provider.ContactsContract.RawContacts} {@link android.provider.ContactsContract.Data} 1585 1586 1587 </dd> 1588 <dt> 1589 1590 </dt> 1591 <dd> 1592 1593 1594 1595 1596 </dd> 1597 <dt> 1598 URIURI MIME {@link android.provider.ContactsContract.CommonDataKinds.CommonColumns#TYPE} {@link android.provider.ContactsContract} 1599 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 {@link android.provider.ContactsContract.DataColumns} 1611 1612 1613 1614 1615 1616 1617 </p> 1618 <p> 1619 1 <code><ContactsAccountType></code> 1 <code><ContactsDataKind></code> <code>contacts.xml</code> 1620 1621 <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 ID Android 1680 1681 {@link android.accounts.AbstractAccountAuthenticator} 1682 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 {@link android.accounts.AccountManager} OAuth2 1700 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 {@link android.app.Service#onBind(Intent) onBind()} {@link android.os.IBinder} 1719 1720 1721 1722 <p> 1723 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html"></a> <code>com.example.android.samplesync.syncadapter.SyncService</code> 1724 1725 1726 </p> 1727 </dd> 1728 <dt> 1729 {@link android.content.AbstractThreadedSyncAdapter} 1730 1731 </dt> 1732 <dd> 1733 1734 {@link android.content.AbstractThreadedSyncAdapter#onPerformSync( Account, Bundle, String, ContentProviderClient, SyncResult) onPerformSync()} 1735 1736 1737 1738 <p> 1739 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html"></a> <code>com.example.android.samplesync.syncadapter.SyncAdapter</code> 1740 1741 1742 </p> 1743 </dd> 1744 <dt> 1745 {@link android.app.Application} 1746 </dt> 1747 <dd> 1748 {@link android.app.Application#onCreate()} {@link android.app.Service#onBind(Intent) onBind()} getter 1749 1750 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 {@link android.app.Service#onBind(Intent) onBind()} {@link android.os.IBinder} 1762 1763 1764 1765 1766 <p> 1767 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html"></a> <code>com.example.android.samplesync.authenticator.AuthenticationService</code> 1768 1769 1770 </p> 1771 </dd> 1772 <dt> 1773 <strong>:</strong> {@link android.accounts.AbstractAccountAuthenticator} 1774 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> <code>com.example.android.samplesync.authenticator.Authenticator</code> 1784 1785 1786 </p> 1787 </dd> 1788 <dt> 1789 XML 1790 </dt> 1791 <dd> 1792 <code><<a href="{@docRoot}guide/topics/manifest/service-element.html">service</a>></code> 1793 1794 1795 <code><<a href="{@docRoot}guide/topics/manifest/meta-data-element.html">meta-data</a>></code> 1796 1797 1798 1799 1800 <ul> 1801 <li> 1802 <code><<a href="{@docRoot}guide/topics/manifest/meta-data-element.html">meta-data</a>></code> XML <code>res/xml/syncadapter.xml</code> 1803 1804 1805 URI 1806 1807 1808 </li> 1809 <li> 1810 <strong>:</strong> <code><<a href="{@docRoot}guide/topics/manifest/meta-data-element.html">meta-data</a>></code> XML <code>res/xml/authenticator.xml</code> 1811 1812 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} {@code android.provider.ContactsContract.StreamItemPhotos} 1825 1826 1827 1828 Android 1829 1830 </p> 1831 <h3 id="StreamText"> </h3> 1832 <p> 1833 {@code android.provider.ContactsContract.StreamItemsColumns#RAW_CONTACT_ID} <code>_ID</code> 1834 1835 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}: {@code android.provider.BaseColumns#_ID} 1865 1866 1867 </li> 1868 <li> 1869 {@code android.provider.ContactsContract.StreamItemsColumns#CONTACT_LOOKUP_KEY}: {@code android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY} 1870 1871 1872 </li> 1873 <li> 1874 {@code android.provider.ContactsContract.StreamItemsColumns#RAW_CONTACT_ID}: {@code android.provider.BaseColumns#_ID} 1875 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 {@link android.text.Html#fromHtml(String) fromHtml()} 1892 1893 1894 1895 </dd> 1896 <dt> 1897 {@code android.provider.ContactsContract.StreamItemsColumns#TIMESTAMP} 1898 </dt> 1899 <dd> 1900 <em></em> 1901 1902 1903 1904 </dd> 1905 </dl> 1906 <p> 1907 {@code android.provider.ContactsContract.StreamItemsColumns#RES_ICON}{@code android.provider.ContactsContract.StreamItemsColumns#RES_LABEL}{@code android.provider.ContactsContract.StreamItemsColumns#RES_PACKAGE} 1908 1909 1910 1911 1912 </p> 1913 <p> 1914 {@code android.provider.ContactsContract.StreamItems} {@code android.provider.ContactsContract.StreamItemsColumns#SYNC1} {@code android.provider.ContactsContract.StreamItemsColumns#SYNC4} 1915 1916 1917 1918 </p> 1919 <h3 id="StreamPhotos"> </h3> 1920 <p> 1921 {@code android.provider.ContactsContract.StreamItemPhotos} 1922 {@code android.provider.ContactsContract.StreamItemPhotosColumns#STREAM_ITEM_ID} {@code android.provider.ContactsContract.StreamItems} {@code android.provider.BaseColumns#_ID} 1923 1924 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} {@code android.provider.ContactsContract.StreamItemPhotosColumns#PHOTO_URI} 1937 1938 1939 1940 1941 </dd> 1942 <dt> 1943 {@code android.provider.ContactsContract.StreamItemPhotosColumns#PHOTO_FILE_ID} 1944 </dt> 1945 <dd> 1946 ID {@link android.provider.ContactsContract.DisplayPhoto#CONTENT_URI DisplayPhoto.CONTENT_URI} 1 URI {@link android.content.ContentResolver#openAssetFileDescriptor(Uri, String) openAssetFileDescriptor()} 1947 1948 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) openAssetFileDescriptor()} 1958 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 {@code android.Manifest.permission#WRITE_SOCIAL_STREAM} 1969 1970 1971 </li> 1972 <li> 1973 {@code android.provider.ContactsContract.StreamItems} 1974 {@code android.provider.ContactsContract.StreamItemsColumns#TIMESTAMP} 1975 1976 1977 URI {@code android.provider.ContactsContract.StreamItems#CONTENT_LIMIT_URI} 1978 1979 URI <code>null</code> 1980 {@code android.provider.ContactsContract.StreamItems#MAX_ITEMS} 1 Cursor 1981 1982 1983 </li> 1984 </ul> 1985 1986 <p> 1987 {@code android.provider.ContactsContract.StreamItems.StreamItemPhotos} 1 {@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 {@code android.provider.ContactsContract.StreamItems} {@code android.provider.ContactsContract.StreamItemPhotos} 2000 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 XML 2018 2019 2020 2021 </li> 2022 </ul> 2023 <p> 2024 2025 <a href="#SyncAdapters"></a> 2026 2 2027 2028 </p> 2029 <h4> </h4> 2030 <p> 2031 2032 2033 </p> 2034 <ol> 2035 <li> 2036 <code>contacts.xml</code> <code>res/xml/</code> 2037 2038 </li> 2039 <li> 2040 <code><ContactsAccountType xmlns:android="http://schemas.android.com/apk/res/android"></code> 2041 2042 2043 </li> 2044 <li> 2045 <code>viewContactNotifyService="<em>serviceclass</em>"</code> <code><em>serviceclass</em></code> 2046 2047 2048 2049 {@link android.app.IntentService} 2050 2051 URI 2052 2053 2054 </li> 2055 </ol> 2056 <p> 2057 2058 </p> 2059 <ol> 2060 <li> 2061 <code>contacts.xml</code> <code>res/xml/</code> 2062 2063 </li> 2064 <li> 2065 <code><ContactsAccountType xmlns:android="http://schemas.android.com/apk/res/android"></code> 2066 2067 2068 </li> 2069 <li> 2070 <code>viewStreamItemActivity="<em>activityclass</em>"</code> <code><em>activityclass</em></code> 2071 2072 2073 2074 2075 </li> 2076 <li> 2077 <code>viewStreamItemPhotoActivity="<em>activityclass</em>"</code> <code><em>activityclass</em></code> 2078 2079 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 2091 </p> 2092 <h4> </h4> 2093 <p> 2094 2095 2096 2097 </p> 2098 <ol> 2099 <li> 2100 <code>contacts.xml</code> <code>res/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> 2117 <code><em>invite_action_label</em></code> [<strong>Add Connection</strong>] 2118 2119 2120 </li> 2121 </ol> 2122 <p class="note"> 2123 <strong>:</strong> <code>ContactsSource</code> <code>ContactsAccountType</code> 2124 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 1 Android UI 2165 2166 2167 </p> 2168 <p> 2169 <code>android:</code> <code><ContactsAccountType></code> 2170 2171 </p> 2172 <p> 2173 <strong>:</strong> 2174 </p> 2175 <dl> 2176 <dt>{@code inviteContactActivity}</dt> 2177 <dd> 2178 [<strong>Add Connection</strong>] 2179 2180 2181 </dd> 2182 <dt>{@code inviteContactActionLabel}</dt> 2183 <dd> 2184 [<strong>Add Connection</strong>] {@code inviteContactActivity} 2185 2186 Follow in my network ID 2187 2188 </dd> 2189 <dt>{@code viewContactNotifyService}</dt> 2190 <dd> 2191 2192 2193 2194 2195 2196 <a href="#SocialStreamInteraction"> </a> 2197 <code>NotifierService.java</code> <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html">SampleSyncAdapter</a> 2198 2199 2200 2201 </dd> 2202 <dt>{@code viewGroupActivity}</dt> 2203 <dd> 2204 2205 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+ {@code viewGroupActivity} Google+ {@code viewGroupActionLabel} 2217 2218 2219 2220 2221 </p> 2222 <p> 2223 ID 2224 </p> 2225 </dd> 2226 <dt>{@code viewStreamItemActivity}</dt> 2227 <dd> 2228 2229 2230 </dd> 2231 <dt>{@code viewStreamItemPhotoActivity}</dt> 2232 <dd> 2233 2234 2235 2236 </dd> 2237 </dl> 2238 <h4 id="SocialStreamDataKind"><ContactsDataKind> </h4> 2239 <p> 2240 <code><ContactsDataKind></code> 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 <code><ContactsDataKind></code> 1 2262 2263 2264 </p> 2265 <p> 2266 <strong>:</strong> 2267 </p> 2268 <dl> 2269 <dt>{@code android:mimeType}</dt> 2270 <dd> 2271 {@link android.provider.ContactsContract.Data} MIME 2272 <code>vnd.android.cursor.item/vnd.example.locationstatus</code> MIME 2273 2274 2275 </dd> 2276 <dt>{@code android:icon}</dt> 2277 <dd> 2278 Android <a href="{@docRoot}guide/topics/resources/drawable-resource.html"> </a> 2279 2280 2281 2282 </dd> 2283 <dt>{@code android:summaryColumn}</dt> 2284 <dd> 2285 2 2286 2287 <a href="#detailColumn">android:detailColumn</a> 2288 2289 </dd> 2290 <dt>{@code android:detailColumn}</dt> 2291 <dd> 2292 2 2 2 2293 {@code android:summaryColumn} 2294 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.Data} {@link android.provider.ContactsContract.CommonDataKinds.GroupMembership} MIME 2314 2315 2316 </p> 2317 <p> 2318 2319 2320 {@link android.provider.ContactsContract.Settings} 2321 2322 {@link android.provider.ContactsContract.SettingsColumns#UNGROUPED_VISIBLE Settings.UNGROUPED_VISIBLE} 1 2323 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 Photo.CONTENT_ITEM_TYPE} 2330 2331 {@link android.provider.ContactsContract.RawContactsColumns#CONTACT_ID} {@code android.provider.BaseColumns#_ID} 2332 2333 2334 {@link android.provider.ContactsContract.Contacts.Photo} {@link android.provider.ContactsContract.Contacts} 2335 2336 {@link android.provider.ContactsContract.RawContacts.DisplayPhoto} {@link android.provider.ContactsContract.RawContacts} 2337 2338 2339 2340 </p> 2341 <p> 2342 {@link android.provider.ContactsContract.Contacts.Photo} {@link android.provider.ContactsContract.RawContacts.DisplayPhoto} 2343 2344 {@link android.provider.ContactsContract.Data} {@code android.provider.BaseColumns#_ID}{@link android.provider.ContactsContract.CommonDataKinds.Photo#CONTENT_ITEM_TYPE Photo.CONTENT_ITEM_TYPE}{@link android.provider.ContactsContract.Data#IS_PRIMARY} 2345 2346 2347 2348 2349 2350 2351 </p> 2352 <p> 2353 {@code android.provider.ContactsContract.StreamItemPhotos} <a href="#StreamPhotos"> </a> 2354 2355 2356 </p> 2357