List of usage examples for android.content ContentResolver call
public final @Nullable Bundle call(@NonNull Uri uri, @NonNull String method, @Nullable String arg, @Nullable Bundle extras)
From source file:com.embeddedlog.LightUpDroid.DeskClock.java
private boolean processMenuClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_item_settings: startActivity(new Intent(DeskClock.this, SettingsActivity.class)); return true; case R.id.menu_item_help: Intent i = item.getIntent();//from w w w . j a v a 2 s .c o m if (i != null) { try { startActivity(i); } catch (ActivityNotFoundException e) { // No activity found to match the intent - ignore } } return true; case R.id.menu_item_night_mode: startActivity(new Intent(DeskClock.this, ScreensaverActivity.class)); case R.id.menu_item_sync_lightuppi: // TODO: update LightUpPiSync to actually sync alarms and then update this bit return true; case R.id.menu_item_push_to_lightuppi: // TODO: update LightUpPiSync to actually push alarms and then update this bit return true; case R.id.menu_item_push_to_phone: // TODO: update LightUpPiSync to actually push alarms and then update this bit String correctString = "android:switcher:" + mViewPager.getId() + ":" + ALARM_TAB_INDEX; new LightUpPiSync(this, correctString).syncPushToPhone(); return true; case R.id.menu_item_reset_db: // Delete the database ContentResolver cr = this.getContentResolver(); cr.call(Uri.parse("content://" + ClockContract.AUTHORITY), "resetAlarmTables", null, null); // Restart the app to repopulate db with default and recreate activities. Intent mStartActivity = new Intent(this, DeskClock.class); int mPendingIntentId = 123456; PendingIntent mPendingIntent = PendingIntent.getActivity(this, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager mgr = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); System.exit(0); return true; default: break; } return true; }
From source file:com.numberx.kkmctimer.DeskClock.java
private boolean processMenuClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_item_settings: startActivity(new Intent(DeskClock.this, SettingsActivity.class)); return true; case R.id.menu_item_help: Intent i = item.getIntent();/* w w w .j av a2 s . c om*/ if (i != null) { try { startActivity(i); } catch (ActivityNotFoundException e) { // No activity found to match the intent - ignore } } return true; case R.id.menu_item_night_mode: startActivity(new Intent(DeskClock.this, ScreensaverActivity.class)); case R.id.menu_item_sync_kkmctimer: // TODO: update KKMCTimerSync to actually sync alarms and then update this bit return true; case R.id.menu_item_push_to_kkmctimer: // TODO: update KKMCTimerSync to actually push alarms and then update this bit return true; case R.id.menu_item_push_to_phone: // TODO: update KKMCTimerSync to actually push alarms and then update this bit String correctString = "android:switcher:" + mViewPager.getId() + ":" + ALARM_TAB_INDEX; new KKMCTimerSync(this, correctString).syncPushToPhone(); return true; case R.id.menu_item_reset_db: // Delete the database ContentResolver cr = this.getContentResolver(); cr.call(Uri.parse("content://" + ClockContract.AUTHORITY), "resetAlarmTables", null, null); // Restart the app to repopulate db with default and recreate activities. Intent mStartActivity = new Intent(this, DeskClock.class); int mPendingIntentId = 123456; PendingIntent mPendingIntent = PendingIntent.getActivity(this, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager mgr = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); System.exit(0); return true; default: break; } return true; }
From source file:com.android.mail.compose.ComposeActivity.java
/** * Use the {@link ContentResolver#call} method to send or save the message. * * If this was successful, this method will return an non-null Bundle instance *//*from w ww .j a v a2s .c o m*/ private static Bundle callAccountSendSaveMethod(final ContentResolver resolver, final Account account, final String method, final SendOrSaveMessage sendOrSaveMessage) { // Copy all of the values from the content values to the bundle final Bundle methodExtras = new Bundle(sendOrSaveMessage.mValues.size()); final Set<Entry<String, Object>> valueSet = sendOrSaveMessage.mValues.valueSet(); for (Entry<String, Object> entry : valueSet) { final Object entryValue = entry.getValue(); final String key = entry.getKey(); if (entryValue instanceof String) { methodExtras.putString(key, (String) entryValue); } else if (entryValue instanceof Boolean) { methodExtras.putBoolean(key, (Boolean) entryValue); } else if (entryValue instanceof Integer) { methodExtras.putInt(key, (Integer) entryValue); } else if (entryValue instanceof Long) { methodExtras.putLong(key, (Long) entryValue); } else { LogUtils.wtf(LOG_TAG, "Unexpected object type: %s", entryValue.getClass().getName()); } } // If the SendOrSaveMessage has some opened fds, add them to the bundle final Bundle fdMap = sendOrSaveMessage.attachmentFds(); if (fdMap != null) { methodExtras.putParcelable(UIProvider.SendOrSaveMethodParamKeys.OPENED_FD_MAP, fdMap); } return resolver.call(account.uri, method, account.uri.toString(), methodExtras); }