Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import android.content.pm.ResolveInfo;

public class Main {
    public static void removeDuplicateWithOrder(List<ResolveInfo> list) {

        if (list == null) {

            return;

        }

        Set<String> set = new HashSet<String>();

        List<ResolveInfo> newList = new ArrayList<ResolveInfo>();

        for (Iterator<ResolveInfo> iter = list.iterator(); iter.hasNext();) {

            ResolveInfo info = (ResolveInfo) iter.next();

            if (set.add(info.activityInfo.packageName)) {

                newList.add(info);

            }
        }

        list.clear();

        list.addAll(newList);

    }
}