Right now I'm working on an android application using voice recog. Basically, I'm wondering what the best search method is once I get String from voice recognition. I'm currently using a linear search on the list of packagename, using the following to get that list:
pkgNames = new ArrayList<String>();
pkgAppsList = (ArrayList<ApplicationInfo>) getPackageManager()
.getInstalledApplications(PackageManager.GET_META_DATA);
// List available packages on phone.
for (ApplicationInfo appInfo : pkgAppsList) {
if (!isSystemPackage(appInfo))
pkgNames.add(appInfo.packageName);
}
I've decide that it's probably better to use the ApplicationInfo list(pkgAppsList) and do a a search on that, but is there a faster way of searching that list than just a simple linear search and using the result to open the Application with an Intent. Right now, all I can think of doing is:
for(ApplicationInfo ai: pkgAppsList){
if((ai.name).contains(voice_recog_result))
//open Launch Intent for ai.packageName
}
Is there a way faster search method I can use with the contains method or a way I can do this without the contains method?