0

I have an array list with all my app labels on the phone

public String[] getAppNames() {
    String[] apps = {};
    String a = "";
    PackageManager packManager = getPackageManager();

    List<ApplicationInfo> installedApps = packManager
            .getInstalledApplications(PackageManager.GET_META_DATA);
    for (ApplicationInfo appInfo : installedApps) {
        a = a + appInfo.loadLabel(packManager) + ",";
        apps = a.split(",");
    }
    return apps;
}

Now i want to get all labels from apps installed yesterday into an extra array list. how do i do that?

2 Answers 2

0

Second answer in this question can help you with finding the date. If date is yesterday, include the app in your list.

4
  • the problem is the package name for each app in getPackageInfo("package.name", 0).firstInstallTime;
    – Tommy
    Jul 7, 2013 at 18:49
  • 1
    Why is it a problem? You can get the packageName field from the ApplicationInfo object.
    – Jong
    Jul 7, 2013 at 18:51
  • oh.. i didn't see the obvious. was looking for something like getPackageName or .loadPackageName.. thanks for your help :)
    – Tommy
    Jul 7, 2013 at 18:52
  • Great :) A tip for the future - Go the the the reference page for the class, and search for the field you want (Ctrl + f). I tried getPackageName() too but searching for packageName found this field.
    – Jong
    Jul 7, 2013 at 18:54
0

Use this code :

PackageManager pm = context.getPackageManager();
ApplicationInfo appInfo = pm.getApplicationInfo("app.package.name", 0);
String appFile = appInfo.sourceDir;
long installed = new File(appFile).lastModified();

The above code having an issue that time returned here will change every time when the package updated. If it doesn't affect your moto then you have to find out date from this returned value and compare to yesterday's date, If it matches put it in another array.

1
  • and the lastModified is always the installation date and doesnt change when its been updated?
    – Tommy
    Jul 8, 2013 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.