Use an
Intent
object to find every
Activity
with
Intent.ACTION_MAIN
Intent.CATEGORY_LAUNCHER
TextView
.
FishActivity.java
main.xml
:
a
ScrollView
instead of a
LinearLayout
.AndroidManifest.xml
:
untouched.List
we got from
queryIntentActivities
?
Just in case it isn’t,
create a copy of the
List
and then
sort
the copy.
Instead of passing an anonymous
OnClickListener
object to the method
setOnClickListener
,
we will pass an anonymous
Comparator
object to the method
sort
.
loadLabel
returns a
CharSequence
,
which is not necessarily a
String
.
That’s why we have to convert it
toString
before we can call the
String
method
compareToIgnoreCase
.
final List<ResolveInfo> copy = new ArrayList<ResolveInfo>(list); Collections.sort(copy, new Comparator<ResolveInfo>() { @Override public int compare(ResolveInfo a, ResolveInfo b) { final String aLabel = a.loadLabel(packageManager).toString(); final String bLabel = b.loadLabel(packageManager).toString(); return aLabel.compareToIgnoreCase(bLabel); } });Then display the copy instead of the original list.
resolveInfo
s
alphabetically,
sort them in order of how closely they
match
ed
what we were looking for.