当前位置: 首页>>代码示例>>Java>>正文


Java ContentProviderClient类代码示例

本文整理汇总了Java中android.content.ContentProviderClient的典型用法代码示例。如果您正苦于以下问题:Java ContentProviderClient类的具体用法?Java ContentProviderClient怎么用?Java ContentProviderClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ContentProviderClient类属于android.content包,在下文中一共展示了ContentProviderClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDocumentThumbnail

import android.content.ContentProviderClient; //导入依赖的package包/类
/**
 * Return thumbnail representing the document at the given URI. Callers are
 * responsible for their own in-memory caching.
 *
 * @param documentUri document to return thumbnail for, which must have
 *            {@link Document#FLAG_SUPPORTS_THUMBNAIL} set.
 * @param size optimal thumbnail size desired. A provider may return a
 *            thumbnail of a different size, but never more than double the
 *            requested size.
 * @param signal signal used to indicate if caller is no longer interested
 *            in the thumbnail.
 * @return decoded thumbnail, or {@code null} if problem was encountered.
 * @see DocumentsProvider#openDocumentThumbnail(String, Point,
 *      CancellationSignal)
 */
public static Bitmap getDocumentThumbnail(
        ContentResolver resolver, Uri documentUri, Point size, CancellationSignal signal) {
	final ContentProviderClient client = ContentProviderClientCompat.acquireUnstableContentProviderClient(resolver, 
			documentUri.getAuthority());
    try {
        if(UsbStorageProvider.AUTHORITY.equals(documentUri.getAuthority())) {
            return ImageUtils.getThumbnail(resolver, documentUri, size.x, size.y);
        }
        return getDocumentThumbnails(client, documentUri, size, signal);
    } catch (Exception e) {
        if (!(e instanceof OperationCanceledException)) {
            Log.w(TAG, "Failed to load thumbnail for " + documentUri + ": " + e);
        }
        return null;
    } finally {
    	ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:34,代码来源:DocumentsContract.java

示例2: uncompressDocument

import android.content.ContentProviderClient; //导入依赖的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

示例3: doInBackground

import android.content.ContentProviderClient; //导入依赖的package包/类
@Override
protected Uri doInBackground(Void... params) {
    final ContentResolver resolver = getContentResolver();
    final DocumentInfo cwd = getCurrentDirectory();
    ContentProviderClient client = null;
    Uri childUri = null;
    try {
        client = DocumentsApplication.acquireUnstableProviderOrThrow(
                resolver, cwd.derivedUri.getAuthority());

        childUri = DocumentsContract.createDocument(
                resolver, cwd.derivedUri, mMimeType, mDisplayName);
    } catch (Exception e) {
        Log.w(TAG, "Failed to create document", e);
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
    if (childUri != null) {
        saveStackBlocking();
    }
    return childUri;
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:23,代码来源:StandaloneActivity.java

示例4: doInBackground

import android.content.ContentProviderClient; //导入依赖的package包/类
@Override
protected Uri doInBackground(Void... params) {
    final ContentResolver resolver = mActivity.getContentResolver();
    ContentProviderClient client = null;
    Uri childUri = null;
    try {
        client = DocumentsApplication.acquireUnstableProviderOrThrow(
                resolver, mCwd.derivedUri.getAuthority());
        childUri = DocumentsContract.createDocument(
                resolver, mCwd.derivedUri, mMimeType, mDisplayName);
    } catch (Exception e) {
        Log.w(DocumentsActivity.TAG, "Failed to create document", e);
        CrashReportingManager.logException(e);
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }

    return childUri;
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:20,代码来源:CreateFileFragment.java

示例5: doInBackground

import android.content.ContentProviderClient; //导入依赖的package包/类
@Override
protected DocumentInfo doInBackground(Void... params) {
    final ContentResolver resolver = mActivity.getContentResolver();
    ContentProviderClient client = null;
    try {
        final Uri childUri = DocumentsContract.renameDocument(
        		resolver, mDoc.derivedUri, mFileName);
        return DocumentInfo.fromUri(resolver, childUri);
    } catch (Exception e) {
        Log.w(TAG, "Failed to rename directory", e);
        CrashReportingManager.logException(e);
        return null;
    } finally {
    	ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:17,代码来源:RenameFragment.java

示例6: doInBackground

import android.content.ContentProviderClient; //导入依赖的package包/类
@Override
    protected DocumentInfo doInBackground(Void... params) {
        final ContentResolver resolver = mActivity.getContentResolver();
        ContentProviderClient client = null;
        try {
client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver, mCwd.derivedUri.getAuthority());
            final Uri childUri = DocumentsContract.createDocument(
            		resolver, mCwd.derivedUri, Document.MIME_TYPE_DIR, mDisplayName);
            return DocumentInfo.fromUri(resolver, childUri);
        } catch (Exception e) {
            Log.w(TAG, "Failed to create directory", e);
            CrashReportingManager.logException(e);
            return null;
        } finally {
        	ContentProviderClientCompat.releaseQuietly(client);
        }
    }
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:18,代码来源:CreateDirectoryFragment.java

示例7: runInternal

import android.content.ContentProviderClient; //导入依赖的package包/类
public void runInternal() {
    ContentProviderClient client = null;
    try {
        client = DocumentsApplication.acquireUnstableProviderOrThrow(
                getContext().getContentResolver(), authority);

        final Uri uri = DocumentsContract.buildRecentDocumentsUri(authority, rootId);
        final Cursor cursor = client.query(
                uri, null, null, null, DirectoryLoader.getQuerySortOrder(mSortOrder));
        mWithRoot = new RootCursorWrapper(authority, rootId, cursor, MAX_DOCS_FROM_ROOT);

    } catch (Exception e) {
        Log.w(TAG, "Failed to load " + authority + ", " + rootId, e);
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }

    set(mWithRoot);

    mFirstPassLatch.countDown();
    if (mFirstPassDone) {
        onContentChanged();
    }
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:25,代码来源:RecentLoader.java

示例8: onPerformSync

import android.content.ContentProviderClient; //导入依赖的package包/类
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
                          SyncResult syncResult) {
    // required for dav4android (ServiceLoader)
    Thread.currentThread().setContextClassLoader(getContext().getClassLoader());

    try {
        syncLocalAndRemoteCollections(account, provider);
        syncCalendarsEvents(account, provider, extras);

        // notify any registered caller that sync operation is finished
        getContext().getContentResolver().notifyChange(GlobalConstant.CONTENT_URI, null, false);
    } catch (InvalidAccountException | CalendarStorageException e) {
        e.printStackTrace();
    }
}
 
开发者ID:6thsolution,项目名称:EasyAppleSyncAdapter,代码行数:17,代码来源:BaseSyncAdapter.java

示例9: onPerformSync

import android.content.ContentProviderClient; //导入依赖的package包/类
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {

    if ( Utility.isNotDuplicateSync(getContext())) {
        if (BuildConfig.DEBUG) Log.d(LOG_TAG,"Start sync!");
        sendSyncStatus(START_SYNC);
        final TvService service = TvApiClient.getClient().create(TvService.class);
        syncCategories(service, provider, syncResult);
        syncChannels(service, provider, syncResult);
        syncPrograms(service, provider, syncResult);
        notifyTvGuide(syncResult.stats.numInserts, syncResult.stats.numIoExceptions);
        prefHelper.setLastSyncTime(getContext().getString(R.string.pref_last_sync_time_key),
                                            System.currentTimeMillis());
        prefHelper.setFirstRun(getContext().getString(R.string.pref_fist_run_key),false);
        sendSyncStatus(END_SYNC);
        if (BuildConfig.DEBUG) Log.d(LOG_TAG,"End sync!");
    }
}
 
开发者ID:graviton57,项目名称:TVGuide,代码行数:19,代码来源:TvGuideSyncAdapter.java

示例10: updateFromUri

import android.content.ContentProviderClient; //导入依赖的package包/类
public void updateFromUri(ContentResolver resolver, Uri uri) throws FileNotFoundException {
    ContentProviderClient client = null;
    Cursor cursor = null;
    try {
        client = DocumentsApplication.acquireUnstableProviderOrThrow(
                resolver, uri.getAuthority());
        cursor = client.query(uri, null, null, null, null);
        if (!cursor.moveToFirst()) {
            throw new FileNotFoundException("Missing details for " + uri);
        }
        updateFromCursor(cursor, uri.getAuthority());
    } catch (Throwable t) {
        throw asFileNotFoundException(t);
    } finally {
        IoUtils.closeQuietly(cursor);
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:19,代码来源:DocumentInfo.java

示例11: doInBackground

import android.content.ContentProviderClient; //导入依赖的package包/类
@Override
protected Uri doInBackground(Void... params) {
    final ContentResolver resolver = getContentResolver();
    final DocumentInfo cwd = getCurrentDirectory();

    ContentProviderClient client = null;
    Uri childUri = null;
    try {
        client = DocumentsApplication.acquireUnstableProviderOrThrow(
                resolver, cwd.derivedUri.getAuthority());
        childUri = DocumentsContract.createDocument(
        		resolver, cwd.derivedUri, mMimeType, mDisplayName);
    } catch (Exception e) {
        Log.w(TAG, "Failed to create document", e);
        CrashReportingManager.logException(e);
    } finally {
    	ContentProviderClientCompat.releaseQuietly(client);
    }

    if (childUri != null) {
        saveStackBlocking();
    }

    return childUri;
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:26,代码来源:DocumentsActivity.java

示例12: isChildDocument

import android.content.ContentProviderClient; //导入依赖的package包/类
public static boolean isChildDocument(ContentProviderClient client, Uri parentDocumentUri,
                                      Uri childDocumentUri) throws RemoteException {

    final Bundle in = new Bundle();
    in.putParcelable(DocumentsContract.EXTRA_URI, parentDocumentUri);
    in.putParcelable(DocumentsContract.EXTRA_TARGET_URI, childDocumentUri);

    final Bundle out = client.call(METHOD_IS_CHILD_DOCUMENT, null, in);
    if (out == null) {
        throw new RemoteException("Failed to get a reponse from isChildDocument query.");
    }
    if (!out.containsKey(DocumentsContract.EXTRA_RESULT)) {
        throw new RemoteException("Response did not include result field..");
    }
    return out.getBoolean(DocumentsContract.EXTRA_RESULT);
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:17,代码来源:DocumentsContract.java

示例13: onPerformSync

import android.content.ContentProviderClient; //导入依赖的package包/类
/**
 * Called by the Android system in response to a request to run the sync adapter. The work
 * required to read data from the network, parse it, and store it in the content provider
 * should be done here. Extending AbstractThreadedSyncAdapter ensures that all methods within SyncAdapter
 * run on a background thread. For this reason, blocking I/O and other long-running tasks can be
 * run <em>in situ</em>, and you don't have to set up a separate thread for them.
 *
 * <p>
 * <p>This is where we actually perform any work required to perform a sync.
 * {@link AbstractThreadedSyncAdapter} guarantees that this will be called on a non-UI thread,
 * so it is safe to perform blocking I/O here.
 * <p>
 *
 * <p>The syncResult argument allows you to pass information back to the method that triggered
 * the sync.
 */
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
                          ContentProviderClient provider, SyncResult syncResult) {

    // Your code to sync data
    // between mobile database and
    // the server goes here.

    for (int i = 0; i < 15; i++) {
        try {
            Thread.sleep(1000);
            Log.i(TAG, ">>>> sleeping the thread: " + (i + 1));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }   // end for

    // write DB data sanity checks at the end.
}
 
开发者ID:jaydeepw,项目名称:simplest-sync-adapter,代码行数:36,代码来源:SyncAdapter.java

示例14: query

import android.content.ContentProviderClient; //导入依赖的package包/类
/**
 * 调用插件里的Provider
 *
 * @see android.content.ContentProviderClient#query(Uri, String[], String, String[], String)
 */
public static Cursor query(Context c, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    ContentProviderClient client = PluginProviderClient.acquireContentProviderClient(c, "");
    if (client != null) {
        try {
            Uri toUri = toCalledUri(c, uri);
            return client.query(toUri, projection, selection, selectionArgs, sortOrder);
        } catch (RemoteException e) {
            if (LogDebug.LOG) {
                Log.d(TAG, e.toString());
            }
        }
    }
    if (LogDebug.LOG) {
        Log.d(TAG, String.format("call query1 %s fail", uri.toString()));
    }
    return null;
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:23,代码来源:PluginProviderClient2.java

示例15: update

import android.content.ContentProviderClient; //导入依赖的package包/类
/**
 * 调用插件里的Provider
 *
 * @see android.content.ContentProviderClient#update(Uri, ContentValues, String, String[])
 */
public static int update(Context c, Uri uri, ContentValues values, String selection, String[] selectionArgs) {
    ContentProviderClient client = PluginProviderClient.acquireContentProviderClient(c, "");
    if (client != null) {
        try {
            Uri toUri = toCalledUri(c, uri);
            return client.update(toUri, values, selection, selectionArgs);
        } catch (RemoteException e) {
            if (LogDebug.LOG) {
                Log.d(TAG, e.toString());
            }
        }
    }
    if (LogDebug.LOG) {
        Log.d(TAG, String.format("call update %s", uri.toString()));
    }
    return -1;
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:23,代码来源:PluginProviderClient2.java


注:本文中的android.content.ContentProviderClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。