Untitled

mail@pastecode.io avatar
unknown
plain_text
17 days ago
1.9 kB
2
Indexable
Never
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Lấy tất cả các ứng dụng đã cài đặt
        PackageManager pm = getPackageManager();
        List<ApplicationInfo> installedApps = pm.getInstalledApplications(PackageManager.GET_META_DATA);

        // Duyệt qua từng ứng dụng
        for (ApplicationInfo appInfo : installedApps) {
            try {
                // Lấy icon ứng dụng
                Drawable appIcon = pm.getApplicationIcon(appInfo);
                String appName = pm.getApplicationLabel(appInfo).toString();
                Log.d("App Info", "App Name: " + appName);

                // Lấy thông tin package của ứng dụng
                PackageInfo packageInfo = pm.getPackageInfo(appInfo.packageName, PackageManager.GET_ACTIVITIES);

                // Lấy các Activity với exported=false
                if (packageInfo.activities != null) {
                    for (ActivityInfo activityInfo : packageInfo.activities) {
                        if (!activityInfo.exported) {
                            Log.d("Exported False Activity", "Activity: " + activityInfo.name + " in " + appName);
                        }
                    }
                }

            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
}
Leave a Comment