android重启app

code
                //获取当前应用的包名和类名
                String packageName = getPackageName();
                String className = getClass().getName();
                //创建Intent
                Intent intent = new Intent(curAct, MainActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                //创建PendingIntent
                PendingIntent pendingIntent = PendingIntent.getActivity(curAct, 0, intent, PendingIntent.FLAG_ONE_SHOT);
                //通过PendingIntent启动Activity
                AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
                manager.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, pendingIntent);
                System.exit(0);

 

相关推荐

  1. androidapp

    2023-12-12 17:57:01       42 阅读
  2. android

    2023-12-12 17:57:01       32 阅读
  3. 手机app没了

    2023-12-12 17:57:01       13 阅读
  4. 双进程交互实现App自动

    2023-12-12 17:57:01       17 阅读
  5. Android 打开热点2.4G系统解决

    2023-12-12 17:57:01       38 阅读
  6. Android SystemUI关机和的UI

    2023-12-12 17:57:01       17 阅读
  7. ES安全

    2023-12-12 17:57:01       33 阅读
  8. OceanBase 方法

    2023-12-12 17:57:01       24 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-12 17:57:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-12 17:57:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-12 17:57:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-12 17:57:01       18 阅读

热门阅读

  1. Python——第五章:json模块

    2023-12-12 17:57:01       42 阅读
  2. 12月10号总结

    2023-12-12 17:57:01       42 阅读
  3. Nginx——记录post请求回执405的一种解决方式

    2023-12-12 17:57:01       50 阅读
  4. 代码编译出错可能的原因

    2023-12-12 17:57:01       65 阅读
  5. OOP

    2023-12-12 17:57:01       54 阅读
  6. 02-python基础学习

    2023-12-12 17:57:01       39 阅读
  7. 【docker】根据docker inspect获取启动参数

    2023-12-12 17:57:01       40 阅读
  8. JVM调优

    JVM调优

    2023-12-12 17:57:01      41 阅读
  9. Go 语言区块链测试实践指南(一):GO单元测试

    2023-12-12 17:57:01       40 阅读
  10. 2023年的PHP项目部署笔记。什么?还有人用PHP?

    2023-12-12 17:57:01       39 阅读