SDK sample---Home
- uses-permission
- <category android:name="android.intent.category.HOME"/>
- Note also the DEFAULT category supplied here: this is required for the
Context.startActivity
method to resolve your activity when its component name is not explicitly specified - private static ArrayList<ApplicationInfo> mApplications;
private static LinkedList<ApplicationInfo> mFavorites;
ArrayList和LinkedList区别 - BroadcastReceiver
registerReceiver 参数
Register a BroadcastReceiver to be run in the main activity thread. The receiver will be called with any broadcast Intent that matches filter, in the main application thread. - 防止重复进入
private void loadApplications(boolean isLaunching) {
if (isLaunching && mApplications != null) {
return;
} - PackageManager
PackageManager manager = getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0);
Collections.sort(apps, new ResolveInfo.DisplayNameComparator(manager)); - 应用程序里面要有一个CATEGORY_LAUNCHER的属性,在这里就很方便得将它们都查找出来。
- 自定义ApplicationInfo用来存放应用程序的信息。
- GridView
setAdapter
mShowApplications.setOnClickListener(new ShowApplications());
private class ShowApplications implements View.OnClickListener {
...showApplications(true);...or...hideApplications();
}- 在XML中定义动画效果。
- 声明周期:onNewIntent、onDestroy、onResume、onRestoreInstanceState...