[Java for Android App Development] amitgoyal95:
how to get list of selected items in the new list and then when click on any item in the new list the app launch,please check out my code

public class AppListAdapter extends BaseAdapter implements OnCheckedChangeListener

{

SparseBooleanArray mCheckStates;

Context context;

private List<ResolveInfo> mApps;

PackageManager pm;

public AppListAdapter(Context context,PackageManager pm,List<ResolveInfo> mApps)

{

this.context=context;

this.pm=pm;

this.mApps=mApps;

mCheckStates = new SparseBooleanArray(mApps.size());

}

[MENTION=439709]override[/MENTION]

public int getCount() {

// TODO Auto-generated method stub

return mApps.size();

}

[MENTION=439709]override[/MENTION]

public ResolveInfo getItem(int index) {

// TODO Auto-generated method stub

return mApps.get(index);

}

[MENTION=439709]override[/MENTION]

public long getItemId(int index) {

// TODO Auto-generated method stub

return index;

}

[MENTION=439709]override[/MENTION]

public View getView(int index, View v, ViewGroup parent)

{

ViewHandler handler;

//	LayoutInflater inflater=null;

//	ApplicationInfo mApplicationInfo=(ApplicationInfo) appitems.get(index);

if(v==null)

{

LayoutInflater inflater=LayoutInflater.from(context);

v=inflater.inflate(R.layout.mycustom_list,null);

handler=new ViewHandler();

handler.iconImage=(ImageView)v.findViewById(R.id.appsimages);

handler.textlable=(TextView)v.findViewById(R.id.appstitle);

handler.checkbox=(CheckBox)v.findViewById(R.id.appscheckBox);

v.setTag(handler);

}

else

{

handler=(ViewHandler)v.getTag();

}

ResolveInfo info = this.mApps.get(index);

handler.iconImage.setImageDrawable(info.loadIcon(pm));

handler.textlable.setText(info.loadLabel(pm).toString());

handler.checkbox.setTag(index);

handler.checkbox.setChecked(mCheckStates.get(index));

handler.checkbox.setOnCheckedChangeListener(this);

return v;

}

public boolean isChecked(int position) {

return mCheckStates.get(position);

}

public void setChecked(int position, boolean isChecked) {

mCheckStates.put(position, isChecked);

}

public void toggle(int position) {

setChecked(position, !isChecked(position));

}

[MENTION=439709]override[/MENTION]

public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

// TODO Auto-generated method stub

mCheckStates.put((Integer) buttonView.getTag(), isChecked);

}

class ViewHandler{

TextView textlable;

ImageView iconImage;

CheckBox checkbox;

}

}

package com.example.mylauncher;

import java.util.ArrayList;

import java.util.List;

import android.nfc.Tag;

import android.os.Bundle;

import android.app.Activity;

import android.app.admin.DeviceAdminReceiver;

import android.app.admin.DevicePolicyManager;

import android.content.ComponentName;

import android.content.Context;

import android.content.Intent;

import android.content.pm.ApplicationInfo;

import android.content.pm.PackageManager;

import android.content.pm.ResolveInfo;

import android.util.Log;

import android.util.SparseBooleanArray;

import android.view.Menu;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.AdapterView;

import android.widget.Button;

import android.widget.GridView;

import android.widget.AdapterView.OnItemClickListener;

import android.widget.ListAdapter;

import android.widget.ListView;

import android.widget.Toast;

public class MainActivity extends Activity implements OnClickListener {

private ListView mListView ;

String TAG;

AppListAdapter adapter;

List appitem;

List<ResolveInfo> list;

private ArrayList results;

// static final int ACTIVATION_REQUEST =47;

[MENTION=439709]override[/MENTION]

protected void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

mListView=(ListView) findViewById(R.id.appslist);

Button button=(Button)findViewById(R.id.save);

button.setOnClickListener(this);

PackageManager pm = this.getPackageManager();

Intent intent = new Intent(Intent.ACTION_MAIN, null);

intent.addCategory(Intent.CATEGORY_LAUNCHER);

list = pm.queryIntentActivities(intent,PackageManager.PERMISSION_GRANTED);

mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

adapter=new AppListAdapter(getApplicationContext(),pm,list);

mListView.setAdapter(adapter);

//	mListView.setOnItemClickListener(this);

}

public void onClick(View view)

{

//	SparseBooleanArray checked = mListView.getCheckedItemPositions();

// ArrayList<ResolveInfo> selectedItems = new ArrayList<ResolveInfo>();

// for (int i = 0; i < checked.size(); i++) {

// // Item position in adapter

// int position = checked.keyAt(i);

// // Add sport if it is checked i.e.) == TRUE!

// if (checked.valueAt(i))

// selectedItems.add(adapter.getItem(position));

// }

//

// String[] outputStrArr = new String[selectedItems.size()];

//

// for (int i = 0; i < selectedItems.size(); i++) {

// outputStrArr = selectedItems.get(i).loadLabel(getPackageManager()).toString();

// }

//

// Intent intent = new Intent(getApplicationContext(),

// ResultActivity.class);

//

// // Create a bundle object

// Bundle b = new Bundle();

// b.putStringArray("selectedItems", outputStrArr);

//

// // Add the bundle to the intent.

// intent.putExtras(b);

//

// // start the ResultActivity

// startActivity(intent);

//

// Toast.makeText(MainActivity.this, outputStrArr.toString(), 1000).show();

SparseBooleanArray checked = mListView.getCheckedItemPositions();

for (int i = 0; i < checked.size(); i++)

{

if(checked.valueAt(i) == true)

{

System.out.println("hello");

Tag tag = (Tag) mListView.getItemAtPosition(checked.keyAt(i));

Log.d("XXXX", i + " hellllllllllllpoo" + tag);

}

}

//	Toast.makeText(MainActivity.this, item, 1000).show();

}

}

please help