package com.siwei.recyclebox.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.siwei.recyclebox.ui.main.MainActivity;

public class BCRUpgradeApk extends BroadcastReceiver {
    private static final String TAG = "BroadcastReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals("android.intent.action.PACKAGE_REPLACED")){
//            Toast.makeText(context,"升级了一个安装包",Toast.LENGTH_SHORT).show();
            Log.e(TAG,"BroadcastReceiver//////////////////:"+intent);
            Intent i = new Intent(context,MainActivity.class);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            context.startActivity(i);
        }
    }
}
