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?

Tommy
  • 27
  • 1
  • 1
  • 7

2 Answers2

0

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

Community
  • 1
  • 1
Jong
  • 9,045
  • 3
  • 34
  • 66
  • the problem is the package name for each app in getPackageInfo("package.name", 0).firstInstallTime; – Tommy Jul 07 '13 at 18:49
  • 1
    Why is it a problem? You can get the `packageName` field from the `ApplicationInfo` object. – Jong Jul 07 '13 at 18:51
  • oh.. i didn't see the obvious. was looking for something like getPackageName or .loadPackageName.. thanks for your help :) – Tommy Jul 07 '13 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 07 '13 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.

Manish Dubey
  • 4,206
  • 8
  • 36
  • 65
  • and the lastModified is always the installation date and doesnt change when its been updated? – Tommy Jul 08 '13 at 11:12