Q:

Launch activity with intent

I've a ListApp activity which list all installed application, what I'm trying to do here is when the user selects an app from the list it should get the intent/info about the selected app and now when the user click the button1, it should open the app(with the help of intent retrieved earlier) which was selected earlier.
ListApp Activity:
 @Override
public void onClick(View arg0) {
    // TODO Auto-generated method stub

    switch (arg0.getId()){

    case R.id.button1:

        //startActivity(app.intent);
        //should start app with the help of info received by selecting app from the  list
        break;
    }

    @Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

//ApplicationInfo app = (ApplicationInfo) parent.getItemAtPosition(position);
    //startActivity(app.intent);        

//instead of launching app, I would like to get the info about the selected app & use it(start app) when clicking button1
}

ApplicationInfo
class ApplicationInfo {

CharSequence title;
Intent intent;
Drawable icon;
boolean filtered;

  final void setActivity(ComponentName className, int launchFlags) {
    intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setComponent(className);
    intent.setFlags(launchFlags);
    }
}

Thanks everyone :)

A:

Get the activity info from the index in the list if you know the package name of the app.
List<ResolveInfo> rInfo =  getPackageManager().queryIntentActivities(new Intent(Intent.ACTION_MAIN),MATCH_DEFAULT_ONLY);

for(ResolveInfo resolveInfo:rInfo){
    if(resolveInfo.activityInfo.packageName.equals("package")){

Set the component  from the resolve info.
        ComponentName chosenName = new ComponentName(
        resolveInfo.activityInfo.packageName,
        resolveInfo.activityInfo.name);
        break;
     }
 }

final Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(chosenName);
startActivity(intent);

Set component as above. 

public ComponentName (String pkg, String cls)
Added in API level 1 Create a new component identifier.
Parameters pkg    The name of the package that the component exists in.
  Can not be null. cls  The name of the class inside of pkg that
  implements the component. Can not be null.

