Java Code Examples for android.content.ContentResolver#acquireContentProviderClient()
The following examples show how to use
android.content.ContentResolver#acquireContentProviderClient() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityHelper.java From ActivityDiary with GNU General Public License v3.0 | 6 votes |
public void reloadAll(){ ContentResolver resolver = ActivityDiaryApplication.getAppContext().getContentResolver(); ContentProviderClient client = resolver.acquireContentProviderClient(ActivityDiaryContract.AUTHORITY); ActivityDiaryContentProvider provider = (ActivityDiaryContentProvider) client.getLocalContentProvider(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { client.close(); } else { client.release(); } provider.resetDatabase(); startQuery(QUERY_ALL_ACTIVITIES, null, ActivityDiaryContract.DiaryActivity.CONTENT_URI, ACTIVITIES_PROJ, SELECTION, null, null); }
Example 2
Source File: LabelProviderClient.java From brailleback with Apache License 2.0 | 6 votes |
/** * Constructs a new client instance for the provider at the given URI. * * @param context The current context. * @param authority The authority of the labels content provider to access. */ public LabelProviderClient(Context context, String authority) { mLabelsContentUri = new Uri.Builder() .scheme("content") .authority(authority) .path(LABELS_PATH) .build(); mPackageSummaryContentUri = new Uri.Builder() .scheme("content") .authority(authority) .path(PACKAGE_SUMMARY_PATH) .build(); final ContentResolver contentResolver = context.getContentResolver(); mClient = contentResolver.acquireContentProviderClient(mLabelsContentUri); if (mClient == null) { LogUtils.log(this, Log.WARN, "Failed to acquire content provider client."); } }
Example 3
Source File: LauncherModel.java From TurboLauncher with Apache License 2.0 | 6 votes |
LauncherModel(LauncherAppState app, IconCache iconCache, AppFilter appFilter) { Context context = app.getContext(); ContentResolver contentResolver = context.getContentResolver(); mAppsCanBeOnRemoveableStorage = Environment .isExternalStorageRemovable(); mOldContentProviderExists = (contentResolver .acquireContentProviderClient(LauncherSettings.Favorites.OLD_CONTENT_URI) != null); mApp = app; mBgAllAppsList = new AllAppsList(iconCache, appFilter); mIconCache = iconCache; final Resources res = context.getResources(); Configuration config = res.getConfiguration(); mPreviousConfigMcc = config.mcc; }
Example 4
Source File: HobbitOpsContentProviderClient.java From mobilecloud-15 with Apache License 2.0 | 6 votes |
/** * Hook method dispatched by the GenericActivity framework to * initialize the HobbitOpsContentProviderClient object after it's * been created. * * @param view The currently active HobbitOps.View. * @param firstTimeIn Set to "true" if this is the first time the * Ops class is initialized, else set to * "false" if called after a runtime * configuration change. */ @Override public void onConfiguration(HobbitOps.View view, boolean firstTimeIn) { super.onConfiguration(view, firstTimeIn); if (firstTimeIn) { // Get this Application context's ContentResolver. ContentResolver cr = view.getApplicationContext().getContentResolver(); // Get the ContentProviderClient associated with this // ContentResolver. mCpc = cr.acquireContentProviderClient (CharacterContract.CharacterEntry.CONTENT_URI); } }
Example 5
Source File: ContentProviderClientCompat.java From FireFiles with Apache License 2.0 | 5 votes |
@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); } }
Example 6
Source File: ContentProviderClientCompat.java From FireFiles with Apache License 2.0 | 5 votes |
@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); } }
Example 7
Source File: ContentProviderClientCompat.java From FireFiles with Apache License 2.0 | 5 votes |
@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); } }
Example 8
Source File: PluginFastInstallProviderProxy.java From springreplugin with Apache License 2.0 | 5 votes |
private static ContentProviderClient getProvider(Context context) { if (sProvider != null) { return sProvider; } synchronized (LOCK) { if (sProvider != null) { return sProvider; } ContentResolver cr = context.getContentResolver(); if (cr == null) { // 不太可能,但保险起见还是返回 if (LogRelease.LOGR) { LogRelease.e(LogDebug.PLUGIN_TAG, "pipp.gp: cr n"); } return null; } ContentProviderClient cpc = cr.acquireContentProviderClient(PluginFastInstallProvider.CONTENT_URI); if (cpc == null) { // 获取Provider失败,可能性不大,先返回空 if (LogRelease.LOGR) { LogRelease.e(LogDebug.PLUGIN_TAG, "pipp.gp: cpc n"); } return null; } // 缓存下来,以备后用 sProvider = cpc; return cpc; } }
Example 9
Source File: CondomProcessTest.java From MiPushFramework with GNU General Public License v3.0 | 5 votes |
@Test public void testProvider() { final ContentResolver resolver = context().getContentResolver(); // Regular provider access final String android_id = Settings.System.getString(resolver, Settings.System.ANDROID_ID); assertNotNull(android_id); final ContentProviderClient client = resolver.acquireContentProviderClient(Settings.AUTHORITY); assertNotNull(client); client.release(); sCondomProcessPackageManager.mCondom.mOutboundJudge = mBlockAllJudge; assertNull(resolver.acquireContentProviderClient("downloads")); }
Example 10
Source File: ContentProviderCompat.java From Android-ServiceManager with MIT License | 5 votes |
public static Bundle call(Uri uri, String method, String arg, Bundle extras) { ContentResolver resolver = ServiceManager.sApplication.getContentResolver(); if (Build.VERSION.SDK_INT >= 11) { return resolver.call(uri, method, arg, extras); } else { ContentProviderClient client = resolver.acquireContentProviderClient(uri); if (client == null) { throw new IllegalArgumentException("Unknown URI " + uri); } try { Object mContentProvider = RefIectUtil.getFieldObject(client, ContentProviderClient.class, "mContentProvider"); if (mContentProvider != null) { //public Bundle call(String method, String request, Bundle args) Object result = null; try { result = RefIectUtil.invokeMethod(mContentProvider, Class.forName("android.content.IContentProvider"), "call", new Class[]{String.class, String.class, Bundle.class}, new Object[]{method, arg, extras}); } catch (ClassNotFoundException e) { e.printStackTrace(); } return (Bundle) result; } } finally { client.release(); } return null; } }
Example 11
Source File: CalendarLoader.java From RememBirthday with GNU General Public License v3.0 | 5 votes |
/** * Updates calendar color */ @SuppressWarnings("deprecation") public static void updateCalendarColor(Context context) { int color = PreferencesManager.getCustomCalendarColor(context); ContentResolver contentResolver = context.getContentResolver(); Uri uri = ContentUris.withAppendedId( CalendarLoader.getBirthdayAdapterUri(context, CalendarContract.Calendars.CONTENT_URI), getCalendar(context)); Log.d(TAG, "Updating calendar color to " + color + " with uri " + uri.toString()); ContentProviderClient client = contentResolver .acquireContentProviderClient(CalendarContract.AUTHORITY); if(client != null) { ContentValues values = new ContentValues(); values.put(CalendarContract.Calendars.CALENDAR_COLOR, color); try { client.update(uri, values, null, null); } catch (RemoteException e) { Log.e(TAG, "Error while updating calendar color!", e); } if (android.os.Build.VERSION.SDK_INT < 24) { client.release(); } else { client.close(); } } }
Example 12
Source File: LabelProviderClient.java From talkback with Apache License 2.0 | 5 votes |
/** * Constructs a new client instance for the provider at the given URI. * * @param context The current context. * @param authority The authority of the labels content provider to access. */ public LabelProviderClient(Context context, String authority) { mLabelsContentUri = new Uri.Builder().scheme("content").authority(authority).path(LABELS_PATH).build(); mPackageSummaryContentUri = new Uri.Builder().scheme("content").authority(authority).path(PACKAGE_SUMMARY_PATH).build(); final ContentResolver contentResolver = context.getContentResolver(); mClient = contentResolver.acquireContentProviderClient(mLabelsContentUri); if (mClient == null) { LogUtils.w(TAG, "Failed to acquire content provider client."); } }
Example 13
Source File: CarefulDatabaseBackupHelper.java From android-device-identification with Apache License 2.0 | 5 votes |
private void stopContentProvider() { List<ProviderInfo> providers = BackupUtil.findContentProviders(mContext); for (ProviderInfo providerInfo : providers) { ContentResolver resolver = mContext.getContentResolver(); ContentProviderClient client = resolver.acquireContentProviderClient(providerInfo.authority); ContentProvider provider = client.getLocalContentProvider(); if (provider instanceof BackupableContentProvider) { ((BackupableContentProvider) provider).closeDatabase(); } client.release(); } }
Example 14
Source File: CompatForContentProvider.java From Android-Plugin-Framework with MIT License | 5 votes |
public static Bundle call(Uri uri, String method, String arg, Bundle extras) { ContentResolver resolver = FairyGlobal.getHostApplication().getContentResolver(); if (Build.VERSION.SDK_INT >= 11) { try { return resolver.call(uri, method, arg, extras); } catch (Exception e) { LogUtil.e("call uri fail", uri, method, arg, extras); } return null; } else { ContentProviderClient client = resolver.acquireContentProviderClient(uri); if (client == null) { throw new IllegalArgumentException("Unknown URI " + uri); } try { HackContentProviderClient hackContentProviderClient = new HackContentProviderClient(client); Object mContentProvider = hackContentProviderClient.getContentProvider(); if (mContentProvider != null) { //public Bundle call(String method, String request, Bundle args) Object result = new HackIContentProvider(mContentProvider).call(method, arg, extras); return (Bundle) result; } } finally { client.release(); } return null; } }
Example 15
Source File: TestStorage.java From android-test with Apache License 2.0 | 5 votes |
private static ContentProviderClient makeContentProviderClient( ContentResolver resolver, Uri uri) { checkNotNull(resolver); ContentProviderClient providerClient = resolver.acquireContentProviderClient(uri); if (null == providerClient) { throw new TestStorageException( String.format( "No content provider registered for: %s. Are all test services apks installed?", uri)); } return providerClient; }
Example 16
Source File: ProviderFacade.java From moVirt with Apache License 2.0 | 5 votes |
@AfterInject void initContentProviderClient() { final ContentResolver contentResolver = context.getContentResolver(); contentClient = contentResolver.acquireContentProviderClient(OVirtContract.BASE_CONTENT_URI); SqlBrite sqlBrite = new SqlBrite.Builder().build(); // TODO possibly refactor to use sqlBrite.wrapDatabaseHelper(), but all queries must use SqlBrite briteResolver = sqlBrite.wrapContentProvider(contentResolver, Schedulers.io()); }