package dgameman1.com.emojiupdaterroot;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import java.io.IOException;
public class DownloadBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Restart?");
alertDialog.setMessage("Android needs to restart to update Emojis.");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "I don't have a choice",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
try {
Runtime.getRuntime().exec("su -c reboot");
} catch (IOException e) {
e.printStackTrace();
}
}
});
alertDialog.show();
}
}
}
So for some reason, this line
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
has a red squiggly line under MainActivity.this
I'm not sure what to change it to, because it works when It's inside my MainActivity.Java just not when I put it inside the BroadCastReceiver.java Class