package com.aplusinformatique.aplusmanager.Classes;

import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.util.Log;

public class ReceiverUninstallDistrimobile extends BroadcastReceiver {

    private static final String TAG = "distrimobile_uninstall";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "onReceive ReceiverUninstallDistrimobile");

        if (intent.getAction().equals("android.intent.action.PACKAGE_FULLY_REMOVED")) {
            String[] a = intent.getData().toString().split(":");
            String packageName = a[a.length - 1];
            Log.d(TAG,"Package removed : " + packageName);
            if (packageName.equals("com.aplusinformatique.distrimobile_v2")) {
                PackageManager p = context.getPackageManager();
                ComponentName componentName = new ComponentName(context, com.aplusinformatique.aplusmanager.Activitys.Activity_First_Launch.class);
                p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
            }
        }
    }
}
