Example usage for android.content Intent EXTRA_DATA_REMOVED

List of usage examples for android.content Intent EXTRA_DATA_REMOVED

Introduction

In this page you can find the example usage for android.content Intent EXTRA_DATA_REMOVED.

Prototype

String EXTRA_DATA_REMOVED

To view the source code for android.content Intent EXTRA_DATA_REMOVED.

Click Source Link

Document

Used as a boolean extra field in android.content.Intent#ACTION_PACKAGE_REMOVED intents to indicate whether this represents a full uninstall (removing both the code and its data) or a partial uninstall (leaving its data, implying that this is an update).

Usage

From source file:eu.faircode.adblocker.Receiver.java

@Override
public void onReceive(final Context context, Intent intent) {
    Log.i(TAG, "Received " + intent);
    Util.logExtras(intent);//from w w w  . j  a va 2  s  . c o m

    if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) {
        // Application added
        if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
            // Show notification
            if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context)) {
                int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
                notifyNewApplication(uid, context);
            }
        }

    } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
        // Application removed
        Rule.clearCache(context);

        if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) {
            // Remove settings
            String packageName = intent.getData().getSchemeSpecificPart();
            Log.i(TAG, "Deleting settings package=" + packageName);
            context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply();

            int uid = intent.getIntExtra(Intent.EXTRA_UID, 0);
            if (uid > 0) {
                NotificationManagerCompat.from(context).cancel(uid); // installed notification
                NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification
            }
        }

    } else {
        // Upgrade settings
        upgrade(true, context);

        // Start service
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        try {
            if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
                if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false))
                    ServiceSinkhole.start("receiver", context);

            } else if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) {
                if (prefs.getBoolean("enabled", false))
                    ServiceSinkhole.start("receiver", context);
                else if (prefs.getBoolean("show_stats", false))
                    ServiceSinkhole.run("receiver", context);
            }
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
            Util.sendCrashReport(ex, context);
        }

        if (Util.isInteractive(context))
            ServiceSinkhole.reloadStats("receiver", context);
    }
}

From source file:com.zhengde163.netguard.Receiver.java

@Override
public void onReceive(final Context context, Intent intent) {
    Log.i(TAG, "Received " + intent);
    Util.logExtras(intent);/*from   w  ww.  java2  s. c o m*/

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) {
        // Application added
        if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
            // Show notification
            if (prefs.getBoolean("install", true)) {
                int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
                notifyNewApplication(uid, context);
            }
        }

    } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
        // Application removed
        Rule.clearCache(context);

        if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) {
            // Remove settings
            String packageName = intent.getData().getSchemeSpecificPart();
            Log.i(TAG, "Deleting settings package=" + packageName);
            context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply();

            int uid = intent.getIntExtra(Intent.EXTRA_UID, 0);
            if (uid > 0) {
                DatabaseHelper.getInstance(context).clearAccess(uid, false);

                NotificationManagerCompat.from(context).cancel(uid); // installed notification
                NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification
            }
        }

    } else {
        // Upgrade settings
        upgrade(true, context);

        // Start service
        try {
            if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
                if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false))
                    ServiceSinkhole.start("receiver", context);

            } else if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) {
                if (prefs.getBoolean("enabled", false))
                    ServiceSinkhole.start("receiver", context);
                else if (prefs.getBoolean("show_stats", false))
                    ServiceSinkhole.run("receiver", context);
            }
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
            Util.sendCrashReport(ex, context);
        }

        if (Util.isInteractive(context))
            ServiceSinkhole.reloadStats("receiver", context);
    }
}

From source file:eu.faircode.netguard.Receiver.java

@Override
public void onReceive(final Context context, Intent intent) {
    Log.i(TAG, "Received " + intent);
    Util.logExtras(intent);/*ww  w .j  av  a 2  s . co m*/

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) {
        // Application added
        if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
            // Show notification
            if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context) && prefs.getBoolean("install", true)) {
                int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
                notifyNewApplication(uid, context);
            }
        }

    } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
        // Application removed
        Rule.clearCache(context);

        if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) {
            // Remove settings
            String packageName = intent.getData().getSchemeSpecificPart();
            Log.i(TAG, "Deleting settings package=" + packageName);
            context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply();

            int uid = intent.getIntExtra(Intent.EXTRA_UID, 0);
            if (uid > 0) {
                DatabaseHelper.getInstance(context).clearAccess(uid, false);

                NotificationManagerCompat.from(context).cancel(uid); // installed notification
                NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification
            }
        }

    } else {
        // Upgrade settings
        upgrade(true, context);

        // Start service
        try {
            if (prefs.getBoolean("enabled", false))
                ServiceSinkhole.start("receiver", context);
            else if (prefs.getBoolean("show_stats", false))
                ServiceSinkhole.run("receiver", context);
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

        if (Util.isInteractive(context))
            ServiceSinkhole.reloadStats("receiver", context);
    }
}

From source file:com.master.metehan.filtereagle.Receiver.java

@Override
public void onReceive(final Context context, Intent intent) {
    Log.i(TAG, "Received " + intent);
    Util.logExtras(intent);//w  ww . j av a  2  s .  c  om

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) {
        // Application added
        if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
            // Show notification
            if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context) && prefs.getBoolean("install", true)) {
                int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
                notifyNewApplication(uid, context);
            }
        }

    } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
        // Application removed
        Rule.clearCache(context);

        if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) {
            // Remove settings
            String packageName = intent.getData().getSchemeSpecificPart();
            Log.i(TAG, "Deleting settings package=" + packageName);
            context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply();

            int uid = intent.getIntExtra(Intent.EXTRA_UID, 0);
            if (uid > 0) {
                DatabaseHelper.getInstance(context).clearAccess(uid, false);

                NotificationManagerCompat.from(context).cancel(uid); // installed notification
                NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification
            }
        }

    } else {
        // Upgrade settings
        upgrade(true, context);

        // Start service
        try {
            if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
                if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false))
                    ServiceSinkhole.start("receiver", context);

            } else if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) {
                if (prefs.getBoolean("enabled", false))
                    ServiceSinkhole.start("receiver", context);
                else if (prefs.getBoolean("show_stats", false))
                    ServiceSinkhole.run("receiver", context);
            }
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
            Util.sendCrashReport(ex, context);
        }

        if (Util.isInteractive(context))
            ServiceSinkhole.reloadStats("receiver", context);
    }
}

From source file:android_network.hetnet.vpn_service.Receiver.java

@Override
public void onReceive(final Context context, Intent intent) {
    Log.i(TAG, "Received " + intent);
    Util.logExtras(intent);//from ww w . j a  va 2  s . c o  m

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) {
        // Application added
        if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
            // Show notification
            if (true) {
                int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
                notifyNewApplication(uid, context);
            }
        }

    } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
        // Application removed
        Rule.clearCache(context);

        if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) {
            // Remove settings
            String packageName = intent.getData().getSchemeSpecificPart();
            Log.i(TAG, "Deleting settings package=" + packageName);
            context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply();

            int uid = intent.getIntExtra(Intent.EXTRA_UID, 0);
            if (uid > 0) {
                DatabaseHelper.getInstance(context).clearAccess(uid, false);

                NotificationManagerCompat.from(context).cancel(uid); // installed notification
                NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification
            }
        }

    } else {
        // Upgrade settings
        upgrade(true, context);

        // Start service
        try {
            if (prefs.getBoolean("enabled", false))
                ServiceSinkhole.start("receiver", context);
            else if (prefs.getBoolean("show_stats", false))
                ServiceSinkhole.run("receiver", context);
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

        if (Util.isInteractive(context))
            ServiceSinkhole.reloadStats("receiver", context);
    }
}

From source file:org.deviceconnect.android.message.DevicePluginContext.java

/**
 * Device Connect Manager????????./*from  w w  w . j a  v  a2  s. com*/
 * @param intent intent
 * @return ?true????false
 */
private boolean checkManagerUninstall(final Intent intent) {
    return Intent.ACTION_PACKAGE_FULLY_REMOVED.equals(intent.getAction())
            && intent.getExtras().getBoolean(Intent.EXTRA_DATA_REMOVED)
            && intent.getDataString().contains("package:org.deviceconnect.android.manager");
}