package safeluck.drive.evaluation.receiver;
|
|
import android.content.BroadcastReceiver;
|
import android.content.Context;
|
import android.content.Intent;
|
import android.widget.Toast;
|
|
import safeluck.drive.evaluation.MainActivity;
|
|
public class PackageReceiver extends BroadcastReceiver {
|
|
@Override
|
public void onReceive(Context context, Intent intent) {
|
// TODO: This method is called when the BroadcastReceiver is receiving
|
// an Intent broadcast.
|
// throw new UnsupportedOperationException("Not yet implemented");
|
if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED") ||
|
intent.getAction().equals("android.intent.action.PACKAGE_REPLACED")) {
|
String pktName =intent.getData().getSchemeSpecificPart();
|
Toast.makeText(context, pktName + " Install Complete", Toast.LENGTH_LONG).show();
|
if (context.getApplicationContext().getPackageName().equals(pktName)) {
|
Intent mBootIntent = new Intent(context, MainActivity.class);
|
mBootIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
context.startActivity(mBootIntent);
|
}
|
} else {
|
Toast.makeText(context, intent.getAction(), Toast.LENGTH_LONG).show();
|
}
|
}
|
}
|