當前位置: 首頁>>代碼示例>>Java>>正文


Java UriMatcher.NO_MATCH屬性代碼示例

本文整理匯總了Java中android.content.UriMatcher.NO_MATCH屬性的典型用法代碼示例。如果您正苦於以下問題:Java UriMatcher.NO_MATCH屬性的具體用法?Java UriMatcher.NO_MATCH怎麽用?Java UriMatcher.NO_MATCH使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.content.UriMatcher的用法示例。


在下文中一共展示了UriMatcher.NO_MATCH屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildUriMatcher

static UriMatcher buildUriMatcher() {
    // I know what you're thinking.  Why create a UriMatcher when you can use regular
    // expressions instead?  Because you're not crazy, that's why.

    // All paths added to the UriMatcher have a corresponding code to return when a match is
    // found.  The code passed into the constructor represents the code to return for the root
    // URI.  It's common to use NO_MATCH as the code for this case.
    final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
    final String authority = WeatherContract.CONTENT_AUTHORITY;

    // For each type of URI you want to add, create a corresponding code.
    matcher.addURI(authority, WeatherContract.PATH_WEATHER, WEATHER);
    matcher.addURI(authority, WeatherContract.PATH_WEATHER + "/*", WEATHER_WITH_LOCATION);
    matcher.addURI(authority, WeatherContract.PATH_WEATHER + "/*/#", WEATHER_WITH_LOCATION_AND_DATE);

    matcher.addURI(authority, WeatherContract.PATH_LOCATION, LOCATION);
    return matcher;
}
 
開發者ID:changja88,項目名稱:Udacity_Sunshine,代碼行數:18,代碼來源:WeatherProvider.java

示例2: buildUriMatcher

/**
 Initialize a new matcher object without any matches,
 then use .addURI(String authority, String path, int match) to add matches
 */
public static UriMatcher buildUriMatcher() {

    // Initialize a UriMatcher with no matches by passing in NO_MATCH to the constructor
    UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);

    /*
      All paths added to the UriMatcher have a corresponding int.
      For each kind of uri you may want to access, add the corresponding match with addURI.
      The two calls below add matches for the task directory and a single item by ID.
     */
    uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS, TASKS);
    uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS + "/#", TASK_WITH_ID);

    return uriMatcher;
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:19,代碼來源:TaskContentProvider.java

示例3: loadResourceFromUri

private InputStream loadResourceFromUri(Uri uri, ContentResolver contentResolver)
    throws FileNotFoundException {
  switch (URI_MATCHER.match(uri)) {
    case ID_CONTACTS_CONTACT:
      return openContactPhotoInputStream(contentResolver, uri);
    case ID_CONTACTS_LOOKUP:
    case ID_LOOKUP_BY_PHONE:
      // If it was a Lookup uri then resolve it first, then continue loading the contact uri.
      uri = ContactsContract.Contacts.lookupContact(contentResolver, uri);
      if (uri == null) {
        throw new FileNotFoundException("Contact cannot be found");
      }
      return openContactPhotoInputStream(contentResolver, uri);
    case ID_CONTACTS_THUMBNAIL:
    case ID_CONTACTS_PHOTO:
    case UriMatcher.NO_MATCH:
    default:
      return contentResolver.openInputStream(uri);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:StreamLocalUriFetcher.java

示例4: buildUriMatcher

/**
 * Builds up a UriMatcher for search suggestion and shortcut refresh queries.
 */
private static UriMatcher buildUriMatcher() {
    UriMatcher matcher =  new UriMatcher(UriMatcher.NO_MATCH);
    // to get definitions...
    matcher.addURI(AUTHORITY, "dictionary", SEARCH_WORDS);
    matcher.addURI(AUTHORITY, "dictionary/#", GET_WORD);
    // to get suggestions...
    matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, SEARCH_SUGGEST);
    matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", SEARCH_SUGGEST);

    /* The following are unused in this implementation, but if we include
     * {@link SearchManager#SUGGEST_COLUMN_SHORTCUT_ID} as a column in our suggestions table, we
     * could expect to receive refresh queries when a shortcutted suggestion is displayed in
     * Quick Search Box, in which case, the following Uris would be provided and we
     * would return a cursor with a single item representing the refreshed suggestion data.
     */
    matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_SHORTCUT, REFRESH_SHORTCUT);
    matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_SHORTCUT + "/*", REFRESH_SHORTCUT);
    return matcher;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:22,代碼來源:DictionaryProvider.java

示例5: buildUriMatcher

/**
 * Initialize a new matcher object without any matches,
 * then use .addURI(String authority, String path, int match) to add matches
 */
public static UriMatcher buildUriMatcher() {

    // Initialize a UriMatcher with no matches by passing in NO_MATCH to the constructor
    UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);

    /*
      All paths added to the UriMatcher have a corresponding int.
      For each kind of uri you may want to access, add the corresponding match with addURI.
      The two calls below add matches for the task directory and a single item by ID.
     */
    uriMatcher.addURI(ArticleContract.AUTHORITY, ArticleContract.PATH_ARTICLES, ARTICLES);


    return uriMatcher;
}
 
開發者ID:ansh94,項目名稱:DailyTech,代碼行數:19,代碼來源:ArticleContentProvider.java

示例6: buildUriMatcher

private static UriMatcher buildUriMatcher() {
    final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
    final String authority = ActivityItemsContract.CONTENT_AUTHORITY;
    matcher.addURI(authority, "items", ITEMS);
    matcher.addURI(authority, "items/#", ITEMS_ID);
    matcher.addURI(authority, "range/#/#", ITEMS_RANGE);

    return matcher;
}
 
開發者ID:OlgaKuklina,項目名稱:GitJourney,代碼行數:9,代碼來源:ActivityItemsProvider.java

示例7: buildUriMatcher

public static UriMatcher buildUriMatcher() {
    final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
    //Mapeamento das URIs referente aos logs de utilização de energia:
    final String energyUseLogAuthority = OhaEnergyUseContract.CONTENT_AUTHORITY;
    matcher.addURI(energyUseLogAuthority, PATH_LOG, CODE_ENERGY_USER_LOG);
    matcher.addURI(energyUseLogAuthority, PATH_DAYS, CODE_ENERGY_USER_DAYS);
    matcher.addURI(energyUseLogAuthority, PATH_BILL, CODE_ENERGY_USER_BILL);
    return matcher;
}
 
開發者ID:brolam,項目名稱:OpenHomeAnalysis,代碼行數:9,代碼來源:OhaEnergyUseProvider.java

示例8: buildUriMatcher

/**
 * A static method to construct a UriMatcher
 * @return a {@link UriMatcher}
 */
public static UriMatcher buildUriMatcher() {
    //initialise a uri matcher
    UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
    //add uris for detection
    uriMatcher.addURI(PlacesContract.AUTHORITY, PlacesContract.PATH, PLACES);
    uriMatcher.addURI(PlacesContract.AUTHORITY, PlacesContract.PATH + "/#", SINGLE_PLACE_WITH_ID);
    uriMatcher.addURI(PlacesContract.AUTHORITY,PlacesContract.TIME_PATH,TIME);
    uriMatcher.addURI(PlacesContract.AUTHORITY,PlacesContract.TIME_PATH + "/#",SINGLE_TIME_WITH_ID);
    return uriMatcher;
}
 
開發者ID:samagra14,項目名稱:Shush,代碼行數:14,代碼來源:PlacesContentProvider.java

示例9: buildUriMatcher

/**
 * Creates the UriMatcher that will match each URI to the CODE_WEATHER and
 * CODE_WEATHER_WITH_DATE constants defined above.
 * <p>
 * It's possible you might be thinking, "Why create a UriMatcher when you can use regular
 * expressions instead? After all, we really just need to match some patterns, and we can
 * use regular expressions to do that right?" Because you're not crazy, that's why.
 * <p>
 * UriMatcher does all the hard work for you. You just have to tell it which code to match
 * with which URI, and it does the rest automagically. Remember, the best programmers try
 * to never reinvent the wheel. If there is a solution for a problem that exists and has
 * been tested and proven, you should almost always use it unless there is a compelling
 * reason not to.
 *
 * @return A UriMatcher that correctly matches the constants for CODE_WEATHER and CODE_WEATHER_WITH_DATE
 */
public static UriMatcher buildUriMatcher() {

    /*
     * All paths added to the UriMatcher have a corresponding code to return when a match is
     * found. The code passed into the constructor of UriMatcher here represents the code to
     * return for the root URI. It's common to use NO_MATCH as the code for this case.
     */
    final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
    final String authority = WeatherContract.CONTENT_AUTHORITY;

    /*
     * For each type of URI you want to add, create a corresponding code. Preferably, these are
     * constant fields in your class so that you can use them throughout the class and you no
     * they aren't going to change. In Sunshine, we use CODE_WEATHER or CODE_WEATHER_WITH_DATE.
     */

    /* This URI is content://com.example.android.sunshine/weather/ */
    matcher.addURI(authority, WeatherContract.PATH_WEATHER, CODE_WEATHER);

    /*
     * This URI would look something like content://com.example.android.sunshine/weather/1472214172
     * The "/#" signifies to the UriMatcher that if PATH_WEATHER is followed by ANY number,
     * that it should return the CODE_WEATHER_WITH_DATE code
     */
    matcher.addURI(authority, WeatherContract.PATH_WEATHER + "/#", CODE_WEATHER_WITH_DATE);

    return matcher;
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:44,代碼來源:WeatherProvider.java

示例10: buildUriMatcher

public static UriMatcher buildUriMatcher() {
    final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
    final String authority = DbContract.CONTENT_AUTHORITY;
    matcher.addURI(authority, DbContract.PATH_PLANT, MATCH_CODE_PLANT);
    matcher.addURI(authority, DbContract.PATH_PLANT + "/#", MATCH_CODE_PLANT_ID);
    return matcher;
}
 
開發者ID:laramartin,項目名稱:android_firebase_green_thumb,代碼行數:7,代碼來源:PlantProvider.java

示例11: buildUriMatcher

private static UriMatcher buildUriMatcher() {
  UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
  matcher.addURI(AUTHORITY, "quran/search", SEARCH_VERSES);
  matcher.addURI(AUTHORITY, "quran/search/*", SEARCH_VERSES);
  matcher.addURI(AUTHORITY, "quran/search/*/*", SEARCH_VERSES);
  matcher.addURI(AUTHORITY, "quran/verse/#/#", GET_VERSE);
  matcher.addURI(AUTHORITY, "quran/verse/*/#/#", GET_VERSE);
  matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY,
      SEARCH_SUGGEST);
  matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*",
      SEARCH_SUGGEST);
  return matcher;
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:13,代碼來源:QuranDataProvider.java

示例12: attachInfo

/**
     * Implementation is provided by the parent class.
     */
    @Override
    public void attachInfo(Context context, ProviderInfo info) {
        mAuthority = info.authority;

        mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
        mMatcher.addURI(mAuthority, "root", MATCH_ROOTS);
        mMatcher.addURI(mAuthority, "root/*", MATCH_ROOT);
        mMatcher.addURI(mAuthority, "root/*/recent", MATCH_RECENT);
        mMatcher.addURI(mAuthority, "root/*/search", MATCH_SEARCH);
        mMatcher.addURI(mAuthority, "document/*", MATCH_DOCUMENT);
        mMatcher.addURI(mAuthority, "document/*/children", MATCH_CHILDREN);
        mMatcher.addURI(mAuthority, "tree/*/document/*", MATCH_DOCUMENT_TREE);
        mMatcher.addURI(mAuthority, "tree/*/document/*/children", MATCH_CHILDREN_TREE);

        // Sanity check our setup
        if (!info.exported) {
            throw new SecurityException("Provider must be exported");
        }
        if (!info.grantUriPermissions) {
            throw new SecurityException("Provider must grantUriPermissions");
        }
/*        if (!android.Manifest.permission.MANAGE_DOCUMENTS.equals(info.readPermission)
                || !android.Manifest.permission.MANAGE_DOCUMENTS.equals(info.writePermission)) {
            throw new SecurityException("Provider must be protected by MANAGE_DOCUMENTS");
        }
*/
        super.attachInfo(context, info);
    }
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:31,代碼來源:DocumentsProvider.java

示例13: buildUriMatcher

private static UriMatcher buildUriMatcher() {
    final UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
    uriMatcher.addURI(AUTHORITY, Path.USER_LOCATION, Code.ALL_USERS);
    uriMatcher.addURI(AUTHORITY, Path.USER_LOCATION + "/#", Code.SINGLE_USER);
    return uriMatcher;
}
 
開發者ID:TigranSarkisian,項目名稱:Boilerplate,代碼行數:6,代碼來源:TlProvider.java

示例14: buildUriMatcher

public static UriMatcher buildUriMatcher() {
    UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);

    uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS, TASKS);
    uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS + "/#", TASK_WITH_ID);
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:6,代碼來源:TaskContentProvider.java

示例15: createUriMatcher

public static UriMatcher createUriMatcher(){
    UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
    uriMatcher.addURI(AUTHORITY, TABLE, TASK);
    uriMatcher.addURI(AUTHORITY, TABLE + "/#", TASK_ID);
    return uriMatcher;
}
 
開發者ID:marckregio,項目名稱:maklib,代碼行數:6,代碼來源:ContentContract.java


注:本文中的android.content.UriMatcher.NO_MATCH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。