안드로이드 개발 질문/답변
(글 수 45,052)
PackageManager packagemanager = this.getPackageManager();
List< ApplicationInfo > appList = packagemanager.getInstalledApplications( 0 );
Log.d("", "----------------------"+ appList.size());
ss = new String[appList.size()];
ArrayList<String> list = new ArrayList<String>();
for (i = 0; i < appList.size(); i++) {
list.add( appList.get(i).loadLabel(packagemanager).toString());
ss[i] = appList.get(i).packageName;
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
listView.setAdapter(adapter);
이소스를 이용해서 어플리케이션을 불러오고있습니다.
그런대 설치된 모든어플리케이션을 가져오더라구요 ..
그게아니라 디폴트어플리케이션 제외하고 가져오는 방법이 따로있는것같은데
검색해도 다 디폴트어플리케이션까지 다가져오는 소스들뿐이네요 ㅠㅠ




ApplicationInfo 의 flags 를 검사하여 ApplicationInfo.FLAG_SYSTEM 이 set 되어 있는 것들을 걸러내면 되겠네요.
http://developer.android.com/reference/android/content/pm/ApplicationInfo.html
int android.content.pm.ApplicationInfo.flags
Flags associated with the application. Any combination of FLAG_SYSTEM, FLAG_DEBUGGABLE, FLAG_HAS_CODE, FLAG_PERSISTENT, FLAG_FACTORY_TEST, and FLAG_ALLOW_TASK_REPARENTING FLAG_ALLOW_CLEAR_USER_DATA, FLAG_UPDATED_SYSTEM_APP, FLAG_TEST_ONLY, FLAG_SUPPORTS_SMALL_SCREENS, FLAG_SUPPORTS_NORMAL_SCREENS, FLAG_SUPPORTS_LARGE_SCREENS, FLAG_RESIZEABLE_FOR_SCREENS, FLAG_SUPPORTS_SCREEN_DENSITIES.
int android.content.pm.ApplicationInfo.FLAG_SYSTEM = 1 [0x1]
Value for flags: if set, this application is installed in the device's system image.