Untitled

mail@pastecode.io avatar
unknown
plain_text
23 days ago
1.5 kB
2
Indexable
Never
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import java.util.List;

public class AllAppActivitiesFetcher {
    public static void getAllActivities(Context context) {
        PackageManager packageManager = context.getPackageManager();
        
        // Lấy tất cả các ứng dụng đã cài đặt
        List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(
                new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER), 
                PackageManager.GET_ACTIVITIES);
        
        for (ResolveInfo resolveInfo : resolveInfos) {
            ActivityInfo activityInfo = resolveInfo.activityInfo;
            String packageName = activityInfo.packageName;
            String activityName = activityInfo.name;
            String label = packageManager.getActivityInfo(activityInfo, 0).loadLabel(packageManager).toString();
            boolean exported = activityInfo.exported;
            boolean enabled = activityInfo.enabled;

            System.out.println("Package: " + packageName);
            System.out.println("Activity Name: " + activityName);
            System.out.println("Label: " + label);
            System.out.println("Exported: " + exported);
            System.out.println("Enabled: " + enabled);
            System.out.println();
        }
    }
}
Leave a Comment