설치된 어플리케이션 목록 가져오기와 실행

Eungi Kim·2020년 10월 27일
1
public void setAppList(Context c) {
    //This is where we build our list of app details, using the app 
    //object we created to store the label, package name and icon
    
    PackageManager pm = c.getPackageManager();
    appsList = new ArrayList<AppInfo>();
    Intent i = new Intent(Intent.ACTION_MAIN, null);
    i.addCategory(Intent.CATEGORY_LAUNCHER);
    List<ResolveInfo> allApps = pm.queryIntentActivities(i, 0);
    for(ResolveInfo ri:allApps) {
        AppInfo app = new AppInfo();
        app.label = ri.loadLabel(pm);
        app.packageName = ri.activityInfo.packageName;
        app.icon = ri.activityInfo.loadIcon(pm);
        appsList.add(app);
    }

}
 


public void onAppButtonClick(View v, String packageName) {
    Intent launchIntent = getPackageManager().getLaunchIntentForPackage(packageName);
    startActivity(launchIntent);
}

https://www.androidauthority.com/make-a-custom-android-launcher-837342-837342

profile
Run and gun and debugun

0개의 댓글