Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. package dgameman1.com.emojiupdaterroot;
  2.  
  3. import android.app.AlertDialog;
  4. import android.app.DownloadManager;
  5. import android.content.BroadcastReceiver;
  6. import android.content.Context;
  7. import android.content.DialogInterface;
  8. import android.content.Intent;
  9.  
  10. import java.io.IOException;
  11. public class DownloadBroadcastReceiver extends BroadcastReceiver {
  12.  
  13. @Override
  14. public void onReceive(Context context, Intent intent) {
  15. String action = intent.getAction();
  16.  
  17. if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
  18. AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
  19. alertDialog.setTitle("Restart?");
  20. alertDialog.setMessage("Android needs to restart to update Emojis.");
  21. alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "I don't have a choice",
  22. new DialogInterface.OnClickListener() {
  23. public void onClick(DialogInterface dialog, int which) {
  24. try {
  25. Runtime.getRuntime().exec("su -c reboot");
  26. } catch (IOException e) {
  27. e.printStackTrace();
  28. }
  29. }
  30. });
  31. alertDialog.show();
  32.  
  33.  
  34.  
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement