Example usage for android.content.pm ChangedPackages getSequenceNumber

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

Introduction

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

Prototype

public int getSequenceNumber() 

Source Link

Document

Returns the last known sequence number for these changes.

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 . j ava 2s .  c  o m*/
        }
    }
}