Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Filter Application Name Along with Package Name using Custom Filter for Search
    primarykey
    data
    text
    <p>I am using a custom filter for a search function on my list of user installed applications. It works great but the search only works for search the application package names. In other words, it only searches the package name and not the actual application name. For example, to search for gmail, if I type in "gmail", I get no results, whereas if I search "gm" I get gmail in the results because it is a part of gmail's package name. </p> <p>I want to search both the package name AND application name though, so how could I do this? Here is my coding:</p> <pre><code> @Override public Filter getFilter() { if(filter == null) { filter = new Filter() { @Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults results = new FilterResults(); List&lt;ApplicationInfo&gt; myFilteredAppList = new ArrayList&lt;ApplicationInfo&gt;(); constraint = constraint.toString().toLowerCase(); if (constraint.length() == 0) { myFilteredAppList.addAll(originalListAppInfo); } for (ApplicationInfo appInfo : originalListAppInfo) { String somefield = appInfo.packageName; if (somefield.toLowerCase().contains(constraint.toString())) { myFilteredAppList.add(appInfo); } } results.count = myFilteredAppList.size(); results.values = myFilteredAppList; return results; } @Override protected void publishResults(CharSequence constraint, FilterResults results) { if(results.values != null) { mListAppInfo = (List&lt;ApplicationInfo&gt;)results.values; notifyDataSetChanged(); } } }; } return filter; } </code></pre> <p>I filter the search in this line:</p> <pre><code>String somefield = appInfo.packageName; </code></pre> <p>as you can see it filters just the packageName not the packageName and ApplicationName.</p> <p>ADDED ERROR:</p> <p><img src="https://i.stack.imgur.com/QEJtY.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload