ActionBar title
- Dapatkan link
- X
- Aplikasi Lainnya
- Dapatkan link
- X
- Aplikasi Lainnya
Intent startupIntent = new Intent(Intent.ACTION_MAIN); startupIntent.addCategory(Intent.CATEGORY_LAUNCHER); final android.content.pm.PackageManager pm = getPackageManager(); List<android.content.pm.ResolveInfo> activities = pm.queryIntentActivities(startupIntent,0); Collections.sort(activities, new Comparator<android.content.pm.ResolveInfo>() { public int compare(android.content.pm.ResolveInfo a, android.content.pm.ResolveInfo b) { android.content.pm.PackageManager pm = getPackageManager(); return String.CASE_INSENSITIVE_ORDER.compare( a.loadLabel(pm).toString(), b.loadLabel(pm).toString()); } }); ArrayAdapter<android.content.pm.ResolveInfo> adapter = new ArrayAdapter<android.content.pm.ResolveInfo>( this, android.R.layout.simple_list_item_1, activities) { public View getView(int pos, View convertView, ViewGroup parent) { View v = super.getView(pos, convertView, parent); TextView tv = (TextView)v; android.content.pm.ResolveInfo ri = getItem(pos); tv.setText(ri.loadLabel(pm)); return v; } }; listview1.setAdapter(adapter); listview1.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapter, View v, int position, long id) { android.content.pm.ResolveInfo resolveInfo = (android.content.pm.ResolveInfo)adapter.getItemAtPosition(position); android.content.pm.ActivityInfo activityInfo = resolveInfo.activityInfo; if (activityInfo == null) return; Intent i = new Intent(Intent.ACTION_MAIN); i.setClassName(activityInfo.applicationInfo.packageName, activityInfo.name); startActivity(i); } });;
Komentar