간단하게 버튼을 누르면
안드로이드 메인에서 메뉴버튼 누르는거처럼
단말기에 저장된 어플 리스트를 출력해주는 기능을 구현하고 싶은데
제가 이제 막 공부하기 시작해서 그런지 잘 모르겠네요 ㅜㅜ 도움 좀 부탁드립니다
http://developer.android.com/resources/samples/Home/src/com/example/android/home/Home.html
/** * Loads the list of installed applications in mApplications. */ private void loadApplications(boolean isLaunching) { if (isLaunching && mApplications != null) { return; } 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)); if (apps != null) { final int count = apps.size(); if (mApplications == null) { mApplications = new ArrayList<ApplicationInfo>(count); } mApplications.clear(); for (int i = 0; i < count; i++) { ApplicationInfo application = new ApplicationInfo(); ResolveInfo info = apps.get(i); application.title = info.loadLabel(manager); application.setActivity(new ComponentName( info.activityInfo.applicationInfo.packageName, info.activityInfo.name), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); application.icon = info.activityInfo.loadIcon(manager); mApplications.add(application); } } }
감사합니다 ^^
로그인 유지
http://developer.android.com/resources/samples/Home/src/com/example/android/home/Home.html