package com.xypower.mpapp;

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

import com.xypower.common.MicroPhotoContext;

public class BootBroadcastReceiver extends BroadcastReceiver {
    private static final String ACTION = "android.intent.action.BOOT_COMPLETED";
    private static final String TAG = "MPLOG";

    @Override
    public void onReceive(Context context, Intent intent) {

        Log.i(TAG, intent.getAction());

        if (ACTION.equals(intent.getAction())) {

            Log.i(TAG, "Start MainActivity");

            /*
            Intent mainIntent = new Intent(context, MainActivity.class);
            mainIntent.putExtra("reboot", 1);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
            try {
                pendingIntent.send();
            } catch (PendingIntent.CanceledException e) {
                e.printStackTrace();
            }


             */
            // MicroPhotoContext.AppConfig appConfig = MicroPhotoContext.getAppConfig(context);

            // MainActivity.startMicroPhotoService(context, appConfig, null);

            Intent mainIntent = new Intent(context, MainActivity.class);
            mainIntent.putExtra("reboot", 1);
            //Intent.FLAG_ACTIVITY_NEW_TASK
            // Intent.FLAG_ACTIVITY_CLEAR_TOP
            mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(mainIntent);

        }
    }
}
