Ipack
Home
Downloads
Creating An Ipack
App Developers

Low-Level Ipack Access

You will need IpackKeys.java for the String constants.

Step One: Query For Ipacks


	context.sendOrderedBroadcast(
    		new Intent( IpackKeys.Actions.QUERY_PACKS ),
    		null, 
    		new BroadcastReceiver() {
    			public void onReceive( Context c, Intent i ) {

    				Bundle packs = getResultExtras( true );
    				
    				for ( String pname : packs.keySet() ) {
    					Log.d( TAG, "found package " + pname + ", label is " + packs.get( pname ).getString( IpackKeys.Extras.LABEL );
				}
			}
		}
	);

Step Two: Query For Icons


	context.sendOrderedBroadcast(
    		new Intent( IpackKeys.Actions.QUERY_ICONS ).setComponent(
    				new ComponentName(
    						ipkgName,	
    						ipkgName + "." + IpackKeys.RECEIVER_NAME
    				)
    		),
    		null, // receiver permission
    		new BroadcastReceiver() {
    			public void onReceive( Context c, Intent i ) {
    				Bundle icons = getResultExtras( true );
				# icons maps display name to resource ID
				# display name is not necessarily the same as resource entry name, it's defined
				# by the creator of the ipack
    				Log.d( TAG, "Got " + icons.size() + " icons from " + ipkgName );
    			}
    		},
    		null,
    		Activity.RESULT_OK,
    		null,
    		null
   	);

You could collect icons from all available Ipacks by not specifying a component, but the resulting resource IDs would be useless because you wouldn't know which package they belong too.

Step Three: Get A Drawable


	try {
		Resources ipackRes = getPackageManager().getResourcesForApplication( ipkgName );
		Drawable d = ipackRes.getDrawable( id );
		if ( d != null )
			Log.d( TAG, "whoop!" ):
	}
	catch ( PackageManager.NameNotFoundException nn) {
		Log.w( TAG, "ipack not found "  + ipkgName );
	}
	catch ( Resources.NotFoundException e ) {
		Log.w( TAG, "missing drawable for ID " + id );
	}