IT. Expert System.

Android Reference

ContactsContract.StreamItemPhotos


android.provider

Class ContactsContract.StreamItemPhotos

  • All Implemented Interfaces:
    BaseColumns, ContactsContract.StreamItemPhotosColumns
    Enclosing class:
    ContactsContract


    public static final class ContactsContract.StreamItemPhotos
    extends Object
    implements BaseColumns, ContactsContract.StreamItemPhotosColumns

    Constants for the stream_item_photos table, which contains photos associated with social stream updates.

    Access to social stream photos requires additional permissions beyond the read/write contact permissions required by the provider. Querying for social stream photos requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.

    Account check

    The content URIs to the insert, update and delete operations are required to have the account information matching that of the owning raw contact as query parameters, namely ContactsContract.SyncColumns.ACCOUNT_TYPE and ContactsContract.SyncColumns.ACCOUNT_NAME. ContactsContract.RawContactsColumns.DATA_SET isn't required.

    Operations

    Insert

    Social stream photo entries are associated with a social stream item. Photos can be inserted into a social stream item in a couple of ways:

    Via the ContactsContract.StreamItems.StreamItemPhotos.CONTENT_DIRECTORY sub-path of a stream item:
     ContentValues values = new ContentValues();
     values.put(StreamItemPhotos.SORT_INDEX, 1);
     values.put(StreamItemPhotos.PHOTO, photoData);
     Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
     ContentUris.appendId(builder, streamItemId);
     builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
     builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
     builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
     Uri photoUri = getContentResolver().insert(builder.build(), values);
     long photoId = ContentUris.parseId(photoUri);
     
    Via the ContactsContract.StreamItems.CONTENT_PHOTO_URI URI:
     ContentValues values = new ContentValues();
     values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
     values.put(StreamItemPhotos.SORT_INDEX, 1);
     values.put(StreamItemPhotos.PHOTO, photoData);
     Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
     builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
     builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
     Uri photoUri = getContentResolver().insert(builder.build(), values);
     long photoId = ContentUris.parseId(photoUri);
     

    Update

    Updates can only be made against a specific ContactsContract.StreamItems.StreamItemPhotos entry, identified by both the stream item ID it belongs to and the stream item photo ID. This can be specified in two ways.

    Via the ContactsContract.StreamItems.StreamItemPhotos.CONTENT_DIRECTORY sub-path of a stream item:
     ContentValues values = new ContentValues();
     values.put(StreamItemPhotos.PHOTO, newPhotoData);
     Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
     ContentUris.appendId(builder, streamItemId);
     builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
     ContentUris.appendId(builder, streamItemPhotoId);
     builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
     builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
     getContentResolver().update(builder.build(), values, null, null);
     
    Via the ContactsContract.StreamItems.CONTENT_PHOTO_URI URI:
     ContentValues values = new ContentValues();
     values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
     values.put(StreamItemPhotos.PHOTO, newPhotoData);
     Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
     builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
     builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
     getContentResolver().update(builder.build(), values);
     

    Delete
    Deletes can be made against either a specific photo item in a stream item, or against all or a selected subset of photo items under a stream item. For example:
    Deleting a single photo via the ContactsContract.StreamItems.StreamItemPhotos.CONTENT_DIRECTORY sub-path of a stream item:
     Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
     ContentUris.appendId(builder, streamItemId);
     builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
     ContentUris.appendId(builder, streamItemPhotoId);
     builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
     builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
     getContentResolver().delete(builder.build(), null, null);
     
    Deleting all photos under a stream item
     Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
     ContentUris.appendId(builder, streamItemId);
     builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
     builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
     builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
     getContentResolver().delete(builder.build(), null, null);
     
    Query
    Querying for a specific photo in a stream item
     Cursor c = getContentResolver().query(
         ContentUris.withAppendedId(
             Uri.withAppendedPath(
                 ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
                 StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
             streamItemPhotoId), null, null, null, null);
     
    Querying for all photos in a stream item
     Cursor c = getContentResolver().query(
         Uri.withAppendedPath(
             ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
             StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
         null, null, null, StreamItemPhotos.SORT_INDEX);
     
    The record will contain both a ContactsContract.StreamItemPhotosColumns.PHOTO_FILE_ID and a ContactsContract.StreamItemPhotosColumns.PHOTO_URI. The ContactsContract.StreamItemPhotosColumns.PHOTO_FILE_ID can be used in conjunction with the ContactsContract.DisplayPhoto API to retrieve photo content, or you can open the ContactsContract.StreamItemPhotosColumns.PHOTO_URI as an asset file, as follows:
     public InputStream openDisplayPhoto(String photoUri) {
         try {
             AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r");
             return fd.createInputStream();
         } catch (IOException e) {
             return null;
         }
     }
     
     
     
    • Field Detail

      • PHOTO

        public static final String PHOTO

        The binary representation of the photo. Any size photo can be inserted; the provider will resize it appropriately for storage and display.

        This is only intended for use when inserting or updating a stream item photo. To retrieve the photo that was stored, open ContactsContract.StreamItemPhotosColumns.PHOTO_URI as an asset file.

        Type: BLOB

        See Also:
        Constant Field Values


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 349 / 158678011. Delta: 0.03613 с