本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}