当前位置: 首页>>代码示例>>Java>>正文


Java PackageManager.resolveContentProvider方法代码示例

本文整理汇总了Java中android.content.pm.PackageManager.resolveContentProvider方法的典型用法代码示例。如果您正苦于以下问题:Java PackageManager.resolveContentProvider方法的具体用法?Java PackageManager.resolveContentProvider怎么用?Java PackageManager.resolveContentProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.pm.PackageManager的用法示例。


在下文中一共展示了PackageManager.resolveContentProvider方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasContentProvider

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static void hasContentProvider(Context context) {
    Validate.notNull(context, "context");
    String appId = Validate.hasAppID();
    PackageManager pm = context.getPackageManager();
    if (pm != null) {
        String providerName = CONTENT_PROVIDER_BASE + appId;
        if (pm.resolveContentProvider(providerName, 0) == null) {
            throw new IllegalStateException(
                    String.format(CONTENT_PROVIDER_NOT_FOUND_REASON, providerName));
        }
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:13,代码来源:Validate.java

示例2: loadPackageIcon

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static Drawable loadPackageIcon(Context context, String authority, int icon) {
    if (icon != 0) {
        if (authority != null) {
            final PackageManager pm = context.getPackageManager();
            final ProviderInfo info = pm.resolveContentProvider(authority, 0);
            if (info != null) {
                return pm.getDrawable(info.packageName, icon, info.applicationInfo);
            }
        } else {
            return ContextCompat.getDrawable(context, icon);
        }
    }
    return null;
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:15,代码来源:IconUtils.java

示例3: initIfNecessary

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private boolean initIfNecessary() {
    if ( !mInit ) {
           Context ctx = getContext();
           PackageManager pm = ctx.getPackageManager();
           ProviderInfo pi = pm.resolveContentProvider(getAuthority(), PackageManager.GET_META_DATA);
           PackageInfo packInfo;
           try {
               packInfo = pm.getPackageInfo(ctx.getPackageName(), 0);
           } catch (NameNotFoundException e1) {
               e1.printStackTrace();
               return false;
           }
           int patchFileVersion;
           int mainFileVersion;
           int appVersionCode = packInfo.versionCode;
           String[] resourceFiles = null;
           if ( null != pi.metaData ) {
               mainFileVersion = pi.metaData.getInt("mainVersion", appVersionCode);
               patchFileVersion = pi.metaData.getInt("patchVersion", appVersionCode);
               String mainFileName = pi.metaData.getString("mainFilename", NO_FILE);
               if ( NO_FILE != mainFileName ) {
                   String patchFileName = pi.metaData.getString("patchFilename", NO_FILE);
                   if ( NO_FILE != patchFileName ) {
                       resourceFiles = new String[] { mainFileName, patchFileName };
                   } else {
                       resourceFiles = new String[] { mainFileName };
                   }
               }
           } else {
               mainFileVersion = patchFileVersion = appVersionCode;
           }
           try {
               if ( null == resourceFiles ) {
                   mAPKExtensionFile = APKExpansionSupport.getAPKExpansionZipFile(ctx, mainFileVersion, patchFileVersion);
               } else {
                   mAPKExtensionFile = APKExpansionSupport.getResourceZipFile(resourceFiles);
               }
               mInit = true;
               return true;
           } catch (IOException e) {
               e.printStackTrace();                
           }
    }
       return false;	    
}
 
开发者ID:12d,项目名称:react-native-videoplayer,代码行数:46,代码来源:APEZProvider.java


注:本文中的android.content.pm.PackageManager.resolveContentProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。