android.app.Activity.managedQuery()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中android.app.Activity.managedQuery()方法的一些代码示例,展示了Activity.managedQuery()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.managedQuery()方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:managedQuery

Activity.managedQuery介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

private String getCalendarUriBase(Activity act) {

  String calendarUriBase = null;
  Uri calendars = Uri.parse("content://calendar/calendars");
  Cursor managedCursor = null;
  try {
    managedCursor = act.managedQuery(calendars, null, null, null, null);
  } catch (Exception e) {
  }
  if (managedCursor != null) {
    calendarUriBase = "content://calendar/";
  } else {
    calendars = Uri.parse("content://com.android.calendar/calendars");
    try {
      managedCursor = act.managedQuery(calendars, null, null, null, null);
    } catch (Exception e) {
    }
    if (managedCursor != null) {
      calendarUriBase = "content://com.android.calendar/";
    }
  }
  return calendarUriBase;
}

代码示例来源:origin: stackoverflow.com

public static String getRealPathFromUri(Activity activity, Uri contentUri) {
  String[] proj = { MediaStore.Images.Media.DATA };
  Cursor cursor = activity.managedQuery(contentUri, proj, null, null, null);
  int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
  cursor.moveToFirst();
  return cursor.getString(column_index);
}

代码示例来源:origin: commonsguy/cw-omnibus

SpinnerAdapter buildPhonesAdapter(Activity a) {
  String[] PROJECTION=new String[] { Contacts._ID,
                       Contacts.DISPLAY_NAME,
                       Phone.NUMBER
                      };
  String[] ARGS={String.valueOf(Phone.TYPE_MOBILE)};
  Cursor c=a.managedQuery(Phone.CONTENT_URI,
              PROJECTION, Phone.TYPE+"=?",
              ARGS, Contacts.DISPLAY_NAME);
  
  SimpleCursorAdapter adapter=new SimpleCursorAdapter(a,
                  android.R.layout.simple_spinner_item,
                  c,
                  new String[] {
                   Contacts.DISPLAY_NAME
                  },
                  new int[] {
                   android.R.id.text1
                  });
                  
  adapter.setDropDownViewResource(
      android.R.layout.simple_spinner_dropdown_item);
  
  return(adapter);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

SpinnerAdapter buildPhonesAdapter(Activity a) {
  String[] PROJECTION=new String[] {  Contacts.Phones._ID,
                    Contacts.Phones.NAME,
                    Contacts.Phones.NUMBER
                   };
  String[] ARGS={String.valueOf(Contacts.Phones.TYPE_MOBILE)};
  Cursor c=a.managedQuery(Contacts.Phones.CONTENT_URI,
              PROJECTION,
              Contacts.Phones.TYPE+"=?", ARGS,
              Contacts.Phones.NAME);
  
  SimpleCursorAdapter adapter=new SimpleCursorAdapter(a,
                  android.R.layout.simple_spinner_item,
                  c,
                  new String[] {
                   Contacts.Phones.NAME
                  },
                  new int[] {
                   android.R.id.text1
                  });
                  
  adapter.setDropDownViewResource(
      android.R.layout.simple_spinner_dropdown_item);
  
  return(adapter);
 }
}

代码示例来源:origin: stackoverflow.com

public String getPath(Uri uri, Activity activity) {
  String[] projection = { MediaColumns.DATA };
  Cursor cursor = activity
      .managedQuery(uri, projection, null, null, null);
  int column_index = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
  cursor.moveToFirst();
  return cursor.getString(column_index);
}

代码示例来源:origin: Blizzard-liu/AndroidUtils

Cursor actualimagecursor = activity.managedQuery(uri, proj, null, null,
    null);
int actual_image_column_index = actualimagecursor

代码示例来源:origin: jingle1267/android-utils

Cursor actualimagecursor = activity.managedQuery(uri, proj, null, null,
    null);
int actual_image_column_index = actualimagecursor

代码示例来源:origin: ac-pm/Inspeckage

activity.managedQuery(uri, null, null, null, null);
} catch (Exception e) {
  XposedBridge.log("InspeckageReceiver - query - " + e.getMessage());

代码示例来源:origin: stackoverflow.com

/**
    * Get a Cursor the history, e.g. records wich have a visits count > 0. Sorted by last visited date.
    * @param currentActivity The parent activity.
    * @return A Cursor to history records.
    * @see Cursor
    */
   public Cursor getHistory(Activity currentActivity) {
       String whereClause = Browser.BookmarkColumns.VISITS + " > 0";
       String orderClause = Browser.BookmarkColumns.DATE + " DESC";
       return currentActivity.managedQuery(android.provider.Browser.BOOKMARKS_URI, Browser.HISTORY_PROJECTION, whereClause, null, orderClause);
   }

代码示例来源:origin: stackoverflow.com

/**
 * @return A managed cursor of email contacts for the given activity.
 */
public static Cursor buildFilteredEmailCursor(Activity activity) {
  final String my_sort_order = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
  String my_selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'";
  String[] eproj = new String[]{
    ContactsContract.Contacts._ID,
    ContactsContract.Contacts.DISPLAY_NAME,
    ContactsContract.CommonDataKinds.Email.DATA};
  Uri uri = android.provider.ContactsContract.CommonDataKinds.Email.CONTENT_URI;
  return activity.managedQuery(uri, eproj, my_selection, null, my_sort_order);
}

代码示例来源:origin: stackoverflow.com

public void callLogs(Activity acc){
  Cursor mCursor = acc.managedQuery(CallLog.Calls.CONTENT_URI, null, null, null, null);

  ...
}

代码示例来源:origin: stackoverflow.com

public String getPath(Uri uri, Activity activity) {
  String[] projection = { MediaColumns.DATA };
  Cursor cursor = activity
      .managedQuery(uri, projection, null, null, null);
  int column_index = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
  cursor.moveToFirst();
  return cursor.getString(column_index);
}

代码示例来源:origin: stackoverflow.com

public static String getRealPathFromUri(Activity activity, Uri contentUri) {
  String[] proj = { MediaStore.Images.Media.DATA };
  Cursor cursor = activity.managedQuery(contentUri, proj, null, null, null);
  int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
  cursor.moveToFirst();
  return cursor.getString(column_index);
}

代码示例来源:origin: ACEMerlin/Kratos

public static String getRealPathFromURI(Uri contentUri, Activity activity) {
  String[] proj = {MediaStore.Images.Media.DATA};
  Cursor cursor = activity.managedQuery(contentUri, proj, null, null, null);
  int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
  cursor.moveToFirst();
  return cursor.getString(column_index);
}

代码示例来源:origin: alhazmy13/MediaPicker

public static String getVideoPath(final Uri uri, final Activity activity) {
  String[] projection = {MediaStore.Images.Media.DATA};
  Cursor cursor = activity.managedQuery(uri, projection, null, null, null);
  if (cursor != null) {
    int column_index = cursor
        .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
  } else
    return null;
}

代码示例来源:origin: stackoverflow.com

Intent i = getIntent();   
Uri tmpSelectedImageUri = i.getData(); 
filename = getPath(tmpSelectedImageUri, ViewVideo.this); 

 public String getPath(Uri uri, Activity activity) { 
  String[] projection = { MediaColumns.DATA };    
  Cursor cursor = activity.managedQuery(uri, projection, null, null, null);    
  int column_index =  cursor.getColumnIndexOrThrow(MediaColumns.DATA);
  cursor.moveToFirst();   
  return cursor.getString(column_index); 
}

代码示例来源:origin: stackoverflow.com

public static String getPath(Uri uri, Activity mActivity) {        
     try {
       String[] projection = {MediaStore.MediaColumns.DATA};
       Cursor cursor = mActivity.managedQuery(uri, projection, null, null, null);
       int column_index = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
       cursor.moveToFirst();           
       return cursor.getString(column_index);
     } catch (IllegalArgumentException e) {
       e.printStackTrace();
       return "";
     } 
   }

代码示例来源:origin: andforce/iBeebo

public static String getPicPathFromUri(Uri uri, Activity activity) {
  String value = uri.getPath();
  if (value.startsWith("/external")) {
    String[] proj = {
        MediaStore.Images.Media.DATA
    };
    Cursor cursor = activity.managedQuery(uri, proj, null, null, null);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
  } else {
    return value;
  }
}

代码示例来源:origin: andforce/iBeebo

public static String getPicPathFromUri(Uri uri, Activity activity) {
  String value = uri.getPath();
  if (value.startsWith("/external")) {
    String[] proj = {
        MediaStore.Images.Media.DATA
    };
    Cursor cursor = activity.managedQuery(uri, proj, null, null, null);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
  } else {
    return value;
  }
}

代码示例来源:origin: sqlcipher/sqlcipher-android-tests

@Override
public boolean execute(SQLiteDatabase database) {
  Activity activity = ZeteticApplication.getInstance().getCurrentActivity();
  Uri providerUri = ZeteticContentProvider.CONTENT_URI;
  android.database.Cursor cursor = activity.managedQuery(providerUri, null, null, null, null);
  StringBuilder buffer = new StringBuilder();
  while (cursor.moveToNext()) {
    buffer.append(cursor.getString(0));
    buffer.append(cursor.getString(1));
  }
  cursor.close();
  return buffer.toString().length() > 0;
}

相关文章

Activity类方法