Java Code Examples for android.content.ContentResolver

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/editor/activity/.

Source file: TaskEditorActivity.java

  18 
vote

@Override protected Uri create(){
  Uri uri=super.create();
  if (uri != null) {
    ContentResolver cr=getContentResolver();
    ArrayList<Integer> reminderMinutes=reminderItemsToMinutes(mReminderItems,mReminderValues);
    long taskId=ContentUris.parseId(uri);
    saveReminders(cr,taskId,reminderMinutes,mOriginalMinutes);
  }
  return uri;
}
 

Example 2

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/deprecated/voice/.

Source file: Hints.java

  18 
vote

public Hints(Context context,SharedPreferences prefs,Display display){
  mContext=context;
  mPrefs=prefs;
  mDisplay=display;
  ContentResolver cr=mContext.getContentResolver();
  mSwipeHintMaxDaysToShow=SettingsUtil.getSettingsInt(cr,SettingsUtil.LATIN_IME_VOICE_INPUT_SWIPE_HINT_MAX_DAYS,DEFAULT_SWIPE_HINT_MAX_DAYS_TO_SHOW);
  mPunctuationHintMaxDisplays=SettingsUtil.getSettingsInt(cr,SettingsUtil.LATIN_IME_VOICE_INPUT_PUNCTUATION_HINT_MAX_DISPLAYS,DEFAULT_PUNCTUATION_HINT_MAX_DISPLAYS);
}
 

Example 3

From project android-xbmcremote, under directory /src/org/xbmc/android/util/.

Source file: SmsPopupUtils.java

  18 
vote

/** 
 * Marks a specific message thread as read - all messages in the thread will be marked read
 */
public static void setThreadRead(Context context,long threadId){
  boolean markRead=false;
  if (!markRead)   return;
  if (threadId > 0) {
    ContentValues values=new ContentValues(1);
    values.put("read",READ_THREAD);
    ContentResolver cr=context.getContentResolver();
    try {
      cr.update(ContentUris.withAppendedId(CONVERSATION_CONTENT_URI,threadId),values,null,null);
    }
 catch (    Exception e) {
    }
  }
}
 

Example 4

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: ApnSettings.java

  18 
vote

private void setSelectedApnKey(String key){
  mSelectedKey=key;
  ContentResolver resolver=getContentResolver();
  ContentValues values=new ContentValues();
  values.put(APN_ID,mSelectedKey);
  resolver.update(PREFERAPN_URI,values,null,null);
}
 

Example 5

From project android_packages_apps_Exchange, under directory /src/com/android/exchange/.

Source file: ExchangeService.java

  18 
vote

/** 
 * Unregister all CalendarObserver's
 */
static public void unregisterCalendarObservers(){
  ExchangeService exchangeService=INSTANCE;
  if (exchangeService == null)   return;
  ContentResolver resolver=exchangeService.mResolver;
  for (  CalendarObserver observer : exchangeService.mCalendarObservers.values()) {
    resolver.unregisterContentObserver(observer);
  }
  exchangeService.mCalendarObservers.clear();
}
 

Example 6

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: GalleryPicker.java

  18 
vote

private void checkScanning(){
  ContentResolver cr=getContentResolver();
  final boolean scanning=ImageManager.isMediaScannerScanning(cr);
  mHandler.post(new Runnable(){
    public void run(){
      checkScanningFinished(scanning);
    }
  }
);
}
 

Example 7

From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/picasa/.

Source file: PicasaContentProvider.java

  18 
vote

public void finish(){
  ContentResolver cr=getContext().getContentResolver();
  if (albumsChanged) {
    cr.notifyChange(ALBUMS_URI,null,false);
  }
  if (photosChanged) {
    cr.notifyChange(PHOTOS_URI,null,false);
  }
  albumsChanged=false;
  photosChanged=false;
}
 

Example 8

From project android_packages_apps_Nfc, under directory /src/com/android/nfc/.

Source file: NfcService.java

  18 
vote

void registerForAirplaneMode(IntentFilter filter){
  final ContentResolver resolver=mContext.getContentResolver();
  final String airplaneModeRadios=Settings.System.getString(resolver,Settings.System.AIRPLANE_MODE_RADIOS);
  final String toggleableRadios=Settings.System.getString(resolver,Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
  mIsAirplaneSensitive=airplaneModeRadios == null ? true : airplaneModeRadios.contains(Settings.System.RADIO_NFC);
  mIsAirplaneToggleable=toggleableRadios == null ? false : toggleableRadios.contains(Settings.System.RADIO_NFC);
  if (mIsAirplaneSensitive) {
    filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
  }
}
 

Example 9

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: SimContacts.java

  18 
vote

@Override public void run(){
  final ContentValues emptyContentValues=new ContentValues();
  final ContentResolver resolver=getContentResolver();
  mCursor.moveToPosition(-1);
  while (!mCanceled && mCursor.moveToNext()) {
    actuallyImportOneSimContact(mCursor,resolver,mAccount);
    mProgressDialog.incrementProgressBy(1);
  }
  mProgressDialog.dismiss();
  finish();
}
 

Example 10

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/.

Source file: AppDetailsFragment.java

  18 
vote

private void doToggle(){
  ContentResolver cr=getActivity().getContentResolver();
  Uri uri=Uri.withAppendedPath(Apps.CONTENT_URI,String.valueOf(mShownIndex));
  ContentValues values=new ContentValues();
  values.put(Apps.ALLOW,mAllow == 1 ? 0 : 1);
  cr.update(uri,values,null,null);
  values.clear();
  values.put(Logs.DATE,System.currentTimeMillis());
  values.put(Logs.TYPE,Logs.LogType.TOGGLE);
  cr.insert(Uri.withAppendedPath(Logs.CONTENT_URI,String.valueOf(mShownIndex)),values);
  Intent intent=new Intent(getActivity(),ResultService.class);
  intent.putExtra(ResultService.EXTRA_ACTION,ResultService.ACTION_RECYCLE);
  getActivity().startService(intent);
}
 

Example 11

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/deprecated/voice/.

Source file: Hints.java

  18 
vote

public Hints(Context context,SharedPreferences prefs,Display display){
  mContext=context;
  mPrefs=prefs;
  mDisplay=display;
  ContentResolver cr=mContext.getContentResolver();
  mSwipeHintMaxDaysToShow=SettingsUtil.getSettingsInt(cr,SettingsUtil.LATIN_IME_VOICE_INPUT_SWIPE_HINT_MAX_DAYS,DEFAULT_SWIPE_HINT_MAX_DAYS_TO_SHOW);
  mPunctuationHintMaxDisplays=SettingsUtil.getSettingsInt(cr,SettingsUtil.LATIN_IME_VOICE_INPUT_PUNCTUATION_HINT_MAX_DISPLAYS,DEFAULT_PUNCTUATION_HINT_MAX_DISPLAYS);
}
 

Example 12

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/dictionaries/.

Source file: AndroidUserDictionary.java

  18 
vote

protected void loadDictionaryAsync(){
  Cursor cursor=getWordsCursor();
  addWords(cursor);
  cursor.close();
  ContentResolver cres=mContext.getContentResolver();
  cres.registerContentObserver(Words.CONTENT_URI,true,mObserver=new ContentObserver(null){
    @Override public void onChange(    boolean self){
      mRequiresReload=true;
    }
  }
);
}
 

Example 13

From project AlarmApp-Android, under directory /src/org/alarmapp/util/.

Source file: RingtoneUtil.java

  17 
vote

/** 
 * @return the uri of the newly installed ringtone
 */
private static Uri installSoundFile(File soundFile,String name){
  ContentValues values=new ContentValues();
  values.put(MediaStore.MediaColumns.DATA,soundFile.getAbsolutePath());
  values.put(MediaStore.MediaColumns.TITLE,name);
  values.put(MediaStore.MediaColumns.MIME_TYPE,"audio/ogg");
  values.put(MediaStore.MediaColumns.SIZE,soundFile.length());
  values.put(MediaStore.Audio.Media.ARTIST,"AlarmApp");
  values.put(MediaStore.Audio.Media.IS_RINGTONE,false);
  values.put(MediaStore.Audio.Media.IS_NOTIFICATION,false);
  values.put(MediaStore.Audio.Media.IS_ALARM,true);
  values.put(MediaStore.Audio.Media.IS_MUSIC,false);
  Uri uri=MediaStore.Audio.Media.getContentUriForPath(soundFile.getAbsolutePath());
  ContentResolver mCr=AlarmApp.getInstance().getContentResolver();
  Uri contentUri=mCr.insert(uri,values);
  LogEx.verbose("Installed Ringtone uri is " + contentUri);
  return Uri.parse(soundFile.getAbsolutePath());
}
 

Example 14

From project android-share-menu, under directory /src/com/eggie5/.

Source file: post_to_eggie5.java

  17 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  Intent intent=getIntent();
  Bundle extras=intent.getExtras();
  String action=intent.getAction();
  if (Intent.ACTION_SEND.equals(action)) {
    if (extras.containsKey(Intent.EXTRA_STREAM)) {
      try {
        Uri uri=(Uri)extras.getParcelable(Intent.EXTRA_STREAM);
        ContentResolver cr=getContentResolver();
        InputStream is=cr.openInputStream(uri);
        byte[] data=getBytesFromFile(is);
        byte[] encoded_data=Base64.encodeBase64(data);
        String data_string=new String(encoded_data);
        SendRequest(data_string);
        return;
      }
 catch (      Exception e) {
        Log.e(this.getClass().getName(),e.toString());
      }
    }
 else     if (extras.containsKey(Intent.EXTRA_TEXT)) {
      return;
    }
  }
}
 

Example 15

From project Android-SyncAdapter-JSON-Server-Example, under directory /src/com/example/android/samplesync/platform/.

Source file: ContactManager.java

  17 
vote

/** 
 * Synchronize raw contacts
 * @param context The context of Authenticator Activity
 * @param account The username for the account
 * @param users The list of users
 */
public static synchronized void syncContacts(Context context,String account,List<User> users){
  long userId;
  long rawContactId=0;
  final ContentResolver resolver=context.getContentResolver();
  final BatchOperation batchOperation=new BatchOperation(context,resolver);
  Log.d(TAG,"In SyncContacts");
  for (  final User user : users) {
    userId=user.getUserId();
    rawContactId=lookupRawContact(resolver,userId);
    if (rawContactId != 0) {
      if (!user.isDeleted()) {
        updateContact(context,resolver,account,user,rawContactId,batchOperation);
      }
 else {
        deleteContact(context,rawContactId,batchOperation);
      }
    }
 else {
      Log.d(TAG,"In addContact");
      if (!user.isDeleted()) {
        addContact(context,account,user,batchOperation);
      }
    }
    if (batchOperation.size() >= 50) {
      batchOperation.execute();
    }
  }
  batchOperation.execute();
}
 

Example 16

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/activity/.

Source file: ShelvesActivity.java

  17 
vote

public Integer doInBackground(Void... params){
  int imported=0;
  try {
    if (mBooks == null)     mBooks=ImportUtilities.loadItems();
    final List<String> list=mBooks;
    final BooksStore booksStore=BookStoreFactory.get(ShelvesActivity.this);
    final int count=list.size();
    final ContentResolver resolver=mResolver;
    final AtomicInteger importCount=mImportCount;
    for (int i=importCount.get(); i < count; i++) {
      publishProgress(i,count);
      if (isCancelled())       return null;
      final String id=list.get(i);
      if (!BooksManager.bookExists(mResolver,id)) {
        if (isCancelled())         return null;
        BooksStore.Book book=BooksManager.loadAndAddBook(resolver,id,booksStore);
        if (book != null) {
          if (Config.LOGD) {
            android.util.Log.d(LOG_TAG,book.toString());
          }
          imported++;
        }
      }
      importCount.incrementAndGet();
    }
  }
 catch (  IOException e) {
    return null;
  }
  return imported;
}
 

Example 17

From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/activities/.

Source file: BacklightActivity.java

  17 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setTitle(R.string.backlight_title);
  addPreferencesFromResource(R.xml.backlight_settings);
  PreferenceScreen prefSet=getPreferenceScreen();
  ContentResolver cr=getContentResolver();
  mFilterEnabled=(CheckBoxPreference)prefSet.findPreference(FILTER_ENABLED);
  mFilterEnabled.setChecked(Settings.System.getInt(cr,Settings.System.LIGHT_FILTER,0) != 0);
  mFilterEnabled.setOnPreferenceChangeListener(this);
  mFilterReset=(ListPreference)prefSet.findPreference(FILTER_RESET);
  mFilterReset.setValue(String.valueOf(Settings.System.getInt(cr,Settings.System.LIGHT_FILTER_RESET,-1)));
  mFilterReset.setOnPreferenceChangeListener(this);
  mFilterWindow=(ListPreference)prefSet.findPreference(FILTER_WINDOW);
  mFilterWindow.setValue(String.valueOf(Settings.System.getInt(cr,Settings.System.LIGHT_FILTER_WINDOW,30000)));
  mFilterWindow.setOnPreferenceChangeListener(this);
  mFilterInterval=(ListPreference)prefSet.findPreference(FILTER_INTERVAL);
  mFilterInterval.setValue(String.valueOf(Settings.System.getInt(cr,Settings.System.LIGHT_FILTER_INTERVAL,1000)));
  mFilterInterval.setOnPreferenceChangeListener(this);
  mLevelsEnabled=(CheckBoxPreference)prefSet.findPreference(LEVELS_ENABLED);
  mLevelsEnabled.setChecked(Settings.System.getInt(cr,Settings.System.LIGHT_SENSOR_CUSTOM,0) != 0);
  mLevelsEnabled.setOnPreferenceChangeListener(this);
  mScreenDim=(ListPreference)prefSet.findPreference(SCREEN_DIM);
  mScreenDim.setValue(String.valueOf(Settings.System.getInt(cr,Settings.System.LIGHT_SCREEN_DIM,android.os.Power.BRIGHTNESS_DIM)));
  mScreenDim.setOnPreferenceChangeListener(this);
  mDecreaseEnabled=(CheckBoxPreference)prefSet.findPreference(DECREASE_ENABLED);
  mDecreaseEnabled.setChecked(Settings.System.getInt(cr,Settings.System.LIGHT_DECREASE,0) != 0);
  mDecreaseEnabled.setOnPreferenceChangeListener(this);
  mDecreaseHysteresis=(ListPreference)prefSet.findPreference(DECREASE_HYSTERESIS);
  mDecreaseHysteresis.setValue(String.valueOf(Settings.System.getInt(cr,Settings.System.LIGHT_HYSTERESIS,50)));
  mDecreaseHysteresis.setOnPreferenceChangeListener(this);
}
 

Example 18

From project android_packages_apps_CMSettings, under directory /src/com/cyanogenmod/settings/activities/.

Source file: Backlight.java

  17 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.backlight_settings);
  PreferenceScreen prefSet=getPreferenceScreen();
  ContentResolver cr=getContentResolver();
  mFilterEnabled=(CheckBoxPreference)prefSet.findPreference(FILTER_ENABLED);
  mFilterEnabled.setChecked(Settings.System.getInt(cr,Settings.System.LIGHT_FILTER,0) != 0);
  mFilterEnabled.setOnPreferenceChangeListener(this);
  mFilterReset=(ListPreference)prefSet.findPreference(FILTER_RESET);
  mFilterReset.setValue(String.valueOf(Settings.System.getInt(cr,Settings.System.LIGHT_FILTER_RESET,-1)));
  mFilterReset.setOnPreferenceChangeListener(this);
  mFilterWindow=(ListPreference)prefSet.findPreference(FILTER_WINDOW);
  mFilterWindow.setValue(String.valueOf(Settings.System.getInt(cr,Settings.System.LIGHT_FILTER_WINDOW,30000)));
  mFilterWindow.setOnPreferenceChangeListener(this);
  mFilterInterval=(ListPreference)prefSet.findPreference(FILTER_INTERVAL);
  mFilterInterval.setValue(String.valueOf(Settings.System.getInt(cr,Settings.System.LIGHT_FILTER_INTERVAL,1000)));
  mFilterInterval.setOnPreferenceChangeListener(this);
  mLevelsEnabled=(CheckBoxPreference)prefSet.findPreference(LEVELS_ENABLED);
  mLevelsEnabled.setChecked(Settings.System.getInt(cr,Settings.System.LIGHT_SENSOR_CUSTOM,0) != 0);
  mLevelsEnabled.setOnPreferenceChangeListener(this);
  mScreenDim=(ListPreference)prefSet.findPreference(SCREEN_DIM);
  mScreenDim.setValue(String.valueOf(Settings.System.getInt(cr,Settings.System.LIGHT_SCREEN_DIM,android.os.Power.BRIGHTNESS_DIM)));
  mScreenDim.setOnPreferenceChangeListener(this);
  mDecreaseEnabled=(CheckBoxPreference)prefSet.findPreference(DECREASE_ENABLED);
  mDecreaseEnabled.setChecked(Settings.System.getInt(cr,Settings.System.LIGHT_DECREASE,0) != 0);
  mDecreaseEnabled.setOnPreferenceChangeListener(this);
  mDecreaseHysteresis=(ListPreference)prefSet.findPreference(DECREASE_HYSTERESIS);
  mDecreaseHysteresis.setValue(String.valueOf(Settings.System.getInt(cr,Settings.System.LIGHT_HYSTERESIS,50)));
  mDecreaseHysteresis.setOnPreferenceChangeListener(this);
}
 

Example 19

From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/data/.

Source file: LocalImage.java

  17 
vote

public LocalImage(Path path,GalleryApp application,int id){
  super(path,nextVersionNumber());
  mApplication=application;
  ContentResolver resolver=mApplication.getContentResolver();
  Uri uri=Images.Media.EXTERNAL_CONTENT_URI;
  Cursor cursor=LocalAlbum.getItemCursor(resolver,uri,PROJECTION,id);
  if (cursor == null) {
    throw new RuntimeException("cannot get cursor for: " + path);
  }
  try {
    if (cursor.moveToNext()) {
      loadFromCursor(cursor);
    }
 else {
      throw new RuntimeException("cannot find data for: " + path);
    }
  }
  finally {
    cursor.close();
  }
}
 

Example 20

From project 2Degrees-Toolbox, under directory /Toolbox/src/biz/shadowservices/DegreesToolbox/.

Source file: DataFetcher.java

  15 
vote

public boolean isAutoSyncEnabled(){
  if (android.os.Build.VERSION.SDK_INT >= 5) {
    Class<ContentResolver> contentResolverClass=ContentResolver.class;
    try {
      Method m=contentResolverClass.getMethod("getMasterSyncAutomatically",null);
      Log.d(TAG,m.toString());
      Log.d(TAG,m.invoke(null,null).toString());
      boolean bool=((Boolean)m.invoke(null,null)).booleanValue();
      return bool;
    }
 catch (    Exception e) {
      Log.d(TAG,"could not determine if autosync is enabled, assuming yes");
      return true;
    }
  }
 else {
    return true;
  }
}
 

Example 21

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/widget/.

Source file: SuggestionsAdapter.java

  15 
vote

public Cursor getSuggestions(String query,int limit){
  Uri.Builder uriBuilder=new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).query("").fragment("");
  uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);
  uriBuilder.appendPath(query);
  if (limit > 0) {
    uriBuilder.appendQueryParameter(SearchManager.SUGGEST_PARAMETER_LIMIT,String.valueOf(limit));
  }
  Uri uri=uriBuilder.build();
  return mContext.getContentResolver().query(uri,null,null,null,null);
}
 

Example 22

From project agit, under directory /agit/src/main/java/com/madgag/agit/sync/.

Source file: AccountAuthenticatorService.java

  15 
vote

private static void initCompatibility(){
  try {
    methodContentResolver_addPeriodicSync=ContentResolver.class.getMethod("addPeriodicSync",new Class[]{Account.class,String.class,Bundle.class,Long.TYPE});
  }
 catch (  NoSuchMethodException nsme) {
    Log.w(TAG,"Periodic sync not available - addPeriodicSync() method not found.",nsme);
  }
}
 

Example 23

From project andlytics, under directory /src/com/github/andlyticsproject/.

Source file: AdmobAuthenticatorActivity.java

  15 
vote

private void finishLogin(){
  Account account=new Account(mUsername,Constants.ACCOUNT_TYPE_ADMOB);
  if (mRequestNewAccount) {
    mAccountManager.addAccountExplicitly(account,mPassword,null);
    ContentResolver.setSyncAutomatically(account,ContactsContract.AUTHORITY,true);
  }
 else {
    mAccountManager.setPassword(account,mPassword);
  }
  Intent intent=new Intent();
  mAuthtoken=mPassword;
  intent.putExtra(AccountManager.KEY_ACCOUNT_NAME,mUsername);
  intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE,Constants.ACCOUNT_TYPE_ADMOB);
  if (mAuthtokenType != null && mAuthtokenType.equals(Constants.AUTHTOKEN_TYPE_ADMOB)) {
    intent.putExtra(AccountManager.KEY_AUTHTOKEN,mAuthtoken);
  }
  setAccountAuthenticatorResult(intent.getExtras());
  setResult(RESULT_OK,intent);
  finish();
}
 

Example 24

From project Android, under directory /AndroidNolesCore/src/io/.

Source file: ScheduleHandler.java

  15 
vote

@Override public ArrayList<ContentProviderOperation> parse(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  final ArrayList<ContentProviderOperation> batch=new ArrayList<ContentProviderOperation>();
  parser.require(XmlPullParser.START_TAG,null,"feed");
  while (parser.next() != XmlPullParser.END_DOCUMENT) {
    if (parser.getEventType() != XmlPullParser.START_TAG) {
      continue;
    }
    final String name=parser.getName();
    if ("entry".equals(name)) {
      final SpreadsheetEntry entry=SpreadsheetEntry.fromParser(parser);
      final Uri scheduleUri=Uri.withAppendedPath(mUri,Uri.encode(entry.get("title")));
      final long localUpdated=queryItemUpdated(scheduleUri,resolver);
      final long serverUpdated=entry.getUpdated();
      LOGV(TAG,"found schedule localUpdated=" + localUpdated + ", server="+ serverUpdated);
      if (localUpdated >= serverUpdated) {
        continue;
      }
      batch.add(ContentProviderOperation.newDelete(scheduleUri).build());
      final ContentProviderOperation.Builder builder=ContentProviderOperation.newInsert(mUri);
      builder.withValue("updated",serverUpdated);
      builder.withValue("date",entry.get("title"));
      builder.withValue("time",entry.get("time"));
      builder.withValue("school",entry.get("school"));
      batch.add(builder.build());
    }
  }
  return batch;
}
 

Example 25

From project android-client_1, under directory /src/com/buddycloud/asmack/.

Source file: ChannelSync.java

  15 
vote

/** 
 * Create a new channel sync thread and start it.
 * @param client The asmack client.
 * @param via The jid used for sending requests.
 * @param resolver The content resolver used for the roster lookup.
 */
public ChannelSync(AsmackClient client,String via,ContentResolver resolver){
  super(client,via);
  this.resolver=resolver;
  roster=new HashMap<String,Long>();
  start();
}
 

Example 26

From project android-cropimage, under directory /src/com/android/camera/.

Source file: BitmapManager.java

  15 
vote

public synchronized void cancelThreadDecoding(Thread t,ContentResolver cr){
  ThreadStatus status=getOrCreateThreadStatus(t);
  status.mState=State.CANCEL;
  if (status.mOptions != null) {
    status.mOptions.requestCancelDecode();
  }
  notifyAll();
  try {
synchronized (status) {
      while (status.mThumbRequesting) {
        Images.Thumbnails.cancelThumbnailRequest(cr,t.getId());
        Video.Thumbnails.cancelThumbnailRequest(cr,t.getId());
        status.wait(200);
      }
    }
  }
 catch (  InterruptedException ex) {
  }
}
 

Example 27

From project android-database-sqlcipher, under directory /src/net/sqlcipher/.

Source file: AbstractCursor.java

  15 
vote

/** 
 * Specifies a content URI to watch for changes.
 * @param cr The content resolver from the caller's context.
 * @param notifyUri The URI to watch for changes. This can be aspecific row URI, or a base URI for a whole class of content.
 */
public void setNotificationUri(ContentResolver cr,Uri notifyUri){
synchronized (mSelfObserverLock) {
    mNotifyUri=notifyUri;
    mContentResolver=cr;
    if (mSelfObserver != null) {
      mContentResolver.unregisterContentObserver(mSelfObserver);
    }
    mSelfObserver=new SelfContentObserver(this);
    mContentResolver.registerContentObserver(mNotifyUri,true,mSelfObserver);
    mSelfObserverRegistered=true;
  }
}
 

Example 28

From project android-joedayz, under directory /Proyectos/FBConnectTest/src/com/facebook/android/.

Source file: Facebook.java

  15 
vote

/** 
 * Get Attribution ID for app install conversion tracking.
 * @param contentResolver
 * @return Attribution ID that will be used for conversion tracking. It will be null only ifthe user has not installed or logged in to the Facebook app.
 */
public static String getAttributionId(ContentResolver contentResolver){
  String[] projection={ATTRIBUTION_ID_COLUMN_NAME};
  Cursor c=contentResolver.query(ATTRIBUTION_ID_CONTENT_URI,projection,null,null,null);
  if (c == null || !c.moveToFirst()) {
    return null;
  }
  String attributionId=c.getString(c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME));
  return attributionId;
}
 

Example 29

From project android-voip-service, under directory /src/main/java/org/linphone/.

Source file: LinphoneManager.java

  15 
vote

public void playDtmf(ContentResolver r,char dtmf){
  try {
    if (Settings.System.getInt(r,Settings.System.DTMF_TONE_WHEN_DIALING) == 0) {
      return;
    }
  }
 catch (  SettingNotFoundException e) {
  }
  getLc().playDtmf(dtmf,-1);
}
 

Example 30

From project android-xbmcremote-sandbox, under directory /src/org/xbmc/android/jsonrpc/io/audio/.

Source file: AlbumHandler.java

  15 
vote

@Override protected ContentValues[] parse(JsonNode result,ContentResolver resolver){
  final long now=System.currentTimeMillis();
  Log.d(TAG,"Building queries for album's drop and create.");
  final ArrayNode albums=(ArrayNode)result.get(AbstractCall.RESULT).get(AudioLibrary.GetAlbums.RESULTS);
  final ContentValues[] batch=new ContentValues[albums.size()];
  for (int i=0; i < albums.size(); i++) {
    final ObjectNode album=(ObjectNode)albums.get(i);
    batch[i]=new ContentValues();
    batch[i].put(SyncColumns.UPDATED,now);
    batch[i].put(Albums.ID,album.get(AudioModel.AlbumDetails.ALBUMID).getIntValue());
    batch[i].put(Albums.TITLE,album.get(AudioModel.AlbumDetails.TITLE).getTextValue());
    batch[i].put(Albums.PREFIX + Artists.ID,album.get(AudioModel.AlbumDetails.ARTISTID).getIntValue());
    batch[i].put(Albums.YEAR,album.get(AudioModel.AlbumDetails.YEAR).getIntValue());
  }
  Log.d(TAG,batch.length + " album queries built in " + (System.currentTimeMillis() - now)+ "ms.");
  return batch;
}
 

Example 31

From project android_packages_apps_QuickSearchBox, under directory /benchmarks/src/com/android/quicksearchbox/benchmarks/.

Source file: SourceLatency.java

  15 
vote

public Cursor getSuggestions(SearchableInfo searchable,String query,int limit){
  if (searchable == null) {
    return null;
  }
  String authority=searchable.getSuggestAuthority();
  if (authority == null) {
    return null;
  }
  Uri.Builder uriBuilder=new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(authority).query("").fragment("");
  final String contentPath=searchable.getSuggestPath();
  if (contentPath != null) {
    uriBuilder.appendEncodedPath(contentPath);
  }
  uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);
  String selection=searchable.getSuggestSelection();
  String[] selArgs=null;
  if (selection != null) {
    selArgs=new String[]{query};
  }
 else {
    uriBuilder.appendPath(query);
  }
  if (limit > 0) {
    uriBuilder.appendQueryParameter(SearchManager.SUGGEST_PARAMETER_LIMIT,String.valueOf(limit));
  }
  Uri uri=uriBuilder.build();
  return getContentResolver().query(uri,null,selection,selArgs,null);
}
 

Example 32

From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/io/.

Source file: LocalBlocksHandler.java

  15 
vote

@Override public ArrayList<ContentProviderOperation> parse(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  final ArrayList<ContentProviderOperation> batch=Lists.newArrayList();
  final String selection=Blocks.BLOCK_TYPE + "=? OR " + Blocks.BLOCK_TYPE+ "=?";
  final String[] selectionArgs={ParserUtils.BLOCK_TYPE_FOOD,ParserUtils.BLOCK_TYPE_OFFICE_HOURS};
  batch.add(ContentProviderOperation.newDelete(Blocks.CONTENT_URI).withSelection(selection,selectionArgs).build());
  int type;
  while ((type=parser.next()) != END_DOCUMENT) {
    if (type == START_TAG && Tags.BLOCK.equals(parser.getName())) {
      batch.add(parseBlock(parser));
    }
  }
  return batch;
}