當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。