当前位置: 首页>>代码示例>>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;未经允许,请勿转载。