當前位置: 首頁>>代碼示例>>Java>>正文


Java ContentResolver.acquireUnstableContentProviderClient方法代碼示例

本文整理匯總了Java中android.content.ContentResolver.acquireUnstableContentProviderClient方法的典型用法代碼示例。如果您正苦於以下問題:Java ContentResolver.acquireUnstableContentProviderClient方法的具體用法?Java ContentResolver.acquireUnstableContentProviderClient怎麽用?Java ContentResolver.acquireUnstableContentProviderClient使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.ContentResolver的用法示例。


在下文中一共展示了ContentResolver.acquireUnstableContentProviderClient方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: uncompressDocument

import android.content.ContentResolver; //導入方法依賴的package包/類
public static boolean uncompressDocument(ContentResolver resolver, Uri fromDocumentUri) {
    final ContentProviderClient client = resolver.acquireUnstableContentProviderClient(
            fromDocumentUri.getAuthority());
    try {
        final Bundle in = new Bundle();
        in.putString(Document.COLUMN_DOCUMENT_ID, getDocumentId(fromDocumentUri));
        in.putParcelable(DocumentsContract.EXTRA_URI, fromDocumentUri);

        resolver.call(fromDocumentUri, METHOD_UNCOMPRESS_DOCUMENT, null, in);
        return true;
    } catch (Exception e) {
        Log.w(TAG, "Failed to uncompress document", e);
        return false;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:18,代碼來源:DocumentsContract.java

示例2: compressDocument

import android.content.ContentResolver; //導入方法依賴的package包/類
public static boolean compressDocument(ContentResolver resolver, Uri fromDocumentUri, ArrayList<String> fromDocumentIds) {
    final ContentProviderClient client = resolver.acquireUnstableContentProviderClient(
            fromDocumentUri.getAuthority());
    try {
        final Bundle in = new Bundle();
        in.putString(Document.COLUMN_DOCUMENT_ID, getDocumentId(fromDocumentUri));
        in.putParcelable(DocumentsContract.EXTRA_URI, fromDocumentUri);
        in.putStringArrayList(DocumentsContract.EXTRA_DOCUMENTS_COMPRESS, fromDocumentIds);
        resolver.call(fromDocumentUri, METHOD_COMPRESS_DOCUMENT, null, in);
        return true;
    } catch (Exception e) {
        Log.w(TAG, "Failed to compress document", e);
        return false;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:18,代碼來源:DocumentsContract.java

示例3: createDocument

import android.content.ContentResolver; //導入方法依賴的package包/類
/**
 * Create a new document with given MIME type and display name.
 *
 * @param parentDocumentUri directory with
 *            {@link DocumentsContract.Document#FLAG_DIR_SUPPORTS_CREATE}
 * @param mimeType MIME type of new document
 * @param displayName name of new document
 * @return newly created document, or {@code null} if failed
 */
public static Uri createDocument(ContentResolver resolver, Uri parentDocumentUri,
                                 String mimeType, String displayName) {
    final ContentProviderClient client = resolver.acquireUnstableContentProviderClient(
            parentDocumentUri.getAuthority());
    try {
        return createDocument(client, parentDocumentUri, mimeType, displayName);
    } catch (Exception e) {
        Log.w(TAG, "Failed to create document", e);
        return null;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:23,代碼來源:DocumentsContract.java

示例4: renameDocument

import android.content.ContentResolver; //導入方法依賴的package包/類
/**
 * Change the display name of an existing document.
 * <p>
 * If the underlying provider needs to create a new
 * {@link DocumentsContract.Document#COLUMN_DOCUMENT_ID} to represent the updated display
 * name, that new document is returned and the original document is no
 * longer valid. Otherwise, the original document is returned.
 *
 * @param documentUri document with {@link DocumentsContract.Document#FLAG_SUPPORTS_RENAME}
 * @param displayName updated name for document
 * @return the existing or new document after the rename, or {@code null} if
 *         failed.
 */
public static Uri renameDocument(ContentResolver resolver, Uri documentUri,
                                 String displayName) {
    final ContentProviderClient client = resolver.acquireUnstableContentProviderClient(
            documentUri.getAuthority());
    try {
        return renameDocument(client, documentUri, displayName);
    } catch (Exception e) {
        Log.w(TAG, "Failed to rename document", e);
        return null;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:27,代碼來源:DocumentsContract.java

示例5: deleteDocument

import android.content.ContentResolver; //導入方法依賴的package包/類
/**
 * Delete the given document.
 *
 * @param documentUri document with {@link Document#FLAG_SUPPORTS_DELETE}
 * @return if the document was deleted successfully.
 */
public static boolean deleteDocument(ContentResolver resolver, Uri documentUri) {
    final ContentProviderClient client = resolver.acquireUnstableContentProviderClient(
            documentUri.getAuthority());
    try {
        deleteDocument(client, documentUri);
        return true;
    } catch (Exception e) {
        Log.w(TAG, "Failed to delete document", e);
        return false;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:20,代碼來源:DocumentsContract.java

示例6: copyDocument

import android.content.ContentResolver; //導入方法依賴的package包/類
/**
 * Copies the given document.
 *
 * @param sourceDocumentUri document with {@link DocumentsContract.Document#FLAG_SUPPORTS_COPY}
 * @param targetParentDocumentUri document which will become a parent of the source
 *         document's copy.
 * @return the copied document, or {@code null} if failed.
 */
public static Uri copyDocument(ContentResolver resolver, Uri sourceDocumentUri,
                               Uri targetParentDocumentUri) {
    final ContentProviderClient client = resolver.acquireUnstableContentProviderClient(
            sourceDocumentUri.getAuthority());
    try {
        return copyDocument(client, sourceDocumentUri, targetParentDocumentUri);
    } catch (Exception e) {
        Log.w(TAG, "Failed to copy document", e);
        return null;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:22,代碼來源:DocumentsContract.java

示例7: moveDocument

import android.content.ContentResolver; //導入方法依賴的package包/類
/**
 * Moves the given document under a new parent.
 *
 * @param sourceDocumentUri document with {@link Document#FLAG_SUPPORTS_MOVE}
 * @param sourceParentDocumentUri parent document of the document to move.
 * @param targetParentDocumentUri document which will become a new parent of the source
 *         document.
 * @return the moved document, or {@code null} if failed.
 */
public static Uri moveDocument(ContentResolver resolver, Uri sourceDocumentUri,
        Uri sourceParentDocumentUri, Uri targetParentDocumentUri) {
    final ContentProviderClient client = resolver.acquireUnstableContentProviderClient(
            sourceDocumentUri.getAuthority());
    try {
        return moveDocument(client, sourceDocumentUri, sourceParentDocumentUri,
                targetParentDocumentUri);
    } catch (Exception e) {
        Log.w(TAG, "Failed to move document", e);
        return null;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:24,代碼來源:DocumentsContract.java

示例8: acquireUnstableContentProviderClient

import android.content.ContentResolver; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
   public static ContentProviderClient acquireUnstableContentProviderClient(ContentResolver resolver, String authority){
	if(Utils.hasJellyBeanMR1()){
    	return resolver.acquireUnstableContentProviderClient(authority);
	}
	else{
        return resolver.acquireContentProviderClient(authority);
	}
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:10,代碼來源:ContentProviderClientCompat.java

示例9: removeDocument

import android.content.ContentResolver; //導入方法依賴的package包/類
/**
 * Removes the given document from a parent directory.
 *
 * <p>In contrast to {@link #deleteDocument} it requires specifying the parent.
 * This method is especially useful if the document can be in multiple parents.
 *
 * @param documentUri document with {@link Document#FLAG_SUPPORTS_REMOVE}
 * @param parentDocumentUri parent document of the document to remove.
 * @return true if the document was removed successfully.
 */
public static boolean removeDocument(ContentResolver resolver, Uri documentUri,
        Uri parentDocumentUri) {
    final ContentProviderClient client = resolver.acquireUnstableContentProviderClient(
            documentUri.getAuthority());
    try {
        removeDocument(client, documentUri, parentDocumentUri);
        return true;
    } catch (Exception e) {
        Log.w(TAG, "Failed to remove document", e);
        return false;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:25,代碼來源:DocumentsContract.java


注:本文中的android.content.ContentResolver.acquireUnstableContentProviderClient方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。