PackageManager getResourcesForApplication - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PackageManager getResourcesForApplication method.

This code example shows how to use the following methods:getResourcesForApplication
	} 
 
	public static Resources getXResources(Context context) throws Throwable {
		String xPackageName = Util.class.getPackage().getName();
		PackageManager pm = context.getPackageManager();
		return pm.getResourcesForApplication(xPackageName);
	} 
 
	public static String getXString(Context context, int id) throws Throwable {
		return getXResources(context).getString(id);
	} 
 
	public static boolean containsIgnoreCase(List<String> strings, String value) {
		for (String string : strings)
			if (string.equalsIgnoreCase(value))
				return true; 
		return false; 
	} 
 
	public static boolean isIntentAvailable(Context context, Intent intent) {
6
CodeRank
This code example shows how to use the following methods:getResourcesForApplication
            } 
 
            public Drawable getFullResIcon(String packageName, int iconId) {
                Resources resources;
                try { 
                    resources = mPackageManager.getResourcesForApplication(packageName);
                } catch (PackageManager.NameNotFoundException e) {
                    resources = null;
                } 
                if (resources != null) {
                    if (iconId != 0) {
                        return getFullResIcon(resources, iconId);
                    } 
                } 
                return getFullResDefaultActivityIcon(); 
            } 
 
            private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h) {
                renderDrawableToBitmap(d, bitmap, x, y, w, h, 1f);
            } 
5
CodeRank
This code example shows how to use the following methods:getPackageInfo, getResourcesForApplication
		pm = ctxt.getPackageManager();
		 
		ComponentName cn = ComponentName.unflattenFromString(packageName);
		 
		try { 
            pInfos = pm.getPackageInfo(cn.getPackageName(), 0);
            remoteRes = pm.getResourcesForApplication(cn.getPackageName());
        } catch (NameNotFoundException e) {
            Log.e(THIS_FILE, "Impossible to get resources from " + cn.toShortString());
            remoteRes = null;
            pInfos = null;
        } 
	} 
	 
	public static Theme getCurrentTheme(Context ctxt) {
	    String themeName = SipConfigManager.getPreferenceStringValue(ctxt, SipConfigManager.THEME);
	    if(!TextUtils.isEmpty(themeName)) {
	        return new Theme(ctxt, themeName);
	    } 
	    return null; 
5
CodeRank
This code example shows how to use the following methods:getResourcesForApplication
     * Given a resource ID, returns the corresponding resource name or null if the package name / 
     * resource ID combination is invalid. 
     */ 
    private String getResourceNameById(String packageName, int resourceId) {
        try { 
            Resources resources = mPackageManager.getResourcesForApplication(packageName);
            return resources.getResourceName(resourceId);
        } catch (NameNotFoundException e) {
            return null; 
        } catch (NotFoundException e) {
            return null; 
        } 
    } 
 
    /** 
     * Scans all packages for directory content providers. 
     */ 
    public void scanAllPackages(boolean rescan) {
        if (rescan || !areTypeResourceIdsValid()) {
            getDbHelper().setProperty(PROPERTY_DIRECTORY_SCAN_COMPLETE, "0");
5
CodeRank
This code example shows how to use the following methods:getResourcesForApplication
    Theme( Context c, String name ) {
        PackageManager pm = c.getPackageManager();
        try { 
            IdPack i = new IdPack();
            i.name = name;
            i.R = pm.getResourcesForApplication( name );
            mResources.add( i );
        }catch( Exception e ) {
            // bad theme name 
        } 
         
        // add app as last resort 
        IdPack i = new IdPack();
        i.name = c.getPackageName();
        i.R = c.getResources();
        mResources.add( i ); 
    } 
 
    // Semi-stacked actions, look in theme, if not found, look in app 
    // this way you can have a generic "button" but also more specific buttons, 
4
CodeRank
This code example shows how to use the following methods:getResourcesForApplication
This code example shows how to use the following methods:getResourcesForApplication
This code example shows how to use the following methods:getResourcesForApplication
    } 
 
    @Override 
    public Resources getResourcesForApplication(String appPackageName)
    throws NameNotFoundException { 
        return wrapped.getResourcesForApplication(appPackageName);
    } 
 
    @Override 
    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
        return wrapped.getPackageArchiveInfo(archiveFilePath, flags);
    } 
 
    @Override 
    public String getInstallerPackageName(String packageName) {
        return wrapped.getInstallerPackageName(packageName);
    } 
 
    @Override 
    public void addPackageToPreferred(String packageName) {
4
CodeRank

Related PackageManager getResourcesForApplication Questions & Answers:

getResourcesForApplication Method Overview
Retrieve the resources associated with an application.
See Code Examples for other Android PackageManager Methods: