Example usage for android.content.pm ChangedPackages getPackageNames

List of usage examples for android.content.pm ChangedPackages getPackageNames

Introduction

In this page you can find the example usage for android.content.pm ChangedPackages getPackageNames.

Prototype

public @NonNull List<String> getPackageNames() 

Source Link

Document

Returns the names of the packages that have changed.

Usage

From source file:com.commonsware.android.sawmonitor.SAWDetector.java

@TargetApi(Build.VERSION_CODES.O)
static void seeSAW(Context ctxt) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctxt);
    int sequence = prefs.getInt(PREF_SEQUENCE, 0);
    PackageManager pm = ctxt.getPackageManager();
    ChangedPackages delta = pm.getChangedPackages(sequence);

    if (delta != null) {
        prefs.edit().putInt(PREF_SEQUENCE, delta.getSequenceNumber()).apply();

        if (sequence > 0) {
            String msg = ctxt.getString(R.string.msg_something);

            for (String pkg : delta.getPackageNames()) {
                SAWDetector.seeSAW(ctxt, pkg, msg);
            }/* w w  w. ja  v  a 2  s .c  o m*/
        }
    }
}