// 方式一:设置intent的flags  直接重启
    Intent intent = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName());
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    //与平时Activity页面跳转一样可传递序列化数据,在Launch页面内获得
    intent.putExtra("REBOOT","reboot");
    startActivity(intent);


   // 方式二:使用AlarmManger  延时重启
    Intent intent2 = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName());
    //与平时Activity页面跳转一样可传递序列化数据,在Launch页面内获得
    intent2.putExtra("REBOOT","reboot");
    PendingIntent restartIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent2, PendingIntent.FLAG_ONE_SHOT);
    AlarmManager mgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
    // 延时1秒重启
    mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, restartIntent);
    android.os.Process.killProcess(android.os.Process.myPid());
 

更多相关文章

  1. 在android中显示网络图片及查看页面源代码
  2. Android(安卓)Touch事件传递机制具体解释 上
  3. 如何正确获得Android内外SD卡路径
  4. Android混合开发
  5. Android中如何使用Intent在Activity之间传递对象[使用Serializab
  6. 用CSS3生成的一个漂亮的android客户端页面
  7. Andrioid SystemProperties和Settings.System介绍,不同应用间传递
  8. Android中去除标题,全屏,获得屏幕方向及键盘状态
  9. android实现swipe的手势及页面拖动动画

随机推荐

  1. 【招聘】杭州蘑菇街招高级前端
  2. 盘点2015年前端早读课专访
  3. 专访|360奇舞团团长@月影
  4. 专访|美的电商高级前端工程师@姬小光
  5. 一文带你学会AQS和并发工具类的关系2
  6. 盘点2015年前端工程师必备图书@前端早读
  7. 【招聘】北京计蒜客招初/中级前端工程师
  8. 【招聘】西安瑞木招web前端
  9. 【招聘】爱奇艺招广告前端
  10. 【招聘】广州37游戏招初/中级前端工程师