Android的API 19:OnBack pressed我想关闭应用程序,并显示所有安装的应用程序 [英] Android API 19 : OnBackPressed I want to close the application and show all the installed apps

查看:180
本文介绍了Android的API 19:OnBack pressed我想关闭应用程序,并显示所有安装的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    Intent intent = new Intent(Intent.ACTION_ALL_APPS);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

这是我的作品code的。
我收到错误未找到可处理的意图action_all_apps活动。
我能理解,同时创造新的意图我没有写任何类。
但是,我不理解要使用的类。
可以的,你指导我实现我的关闭应用程序,并显示所有安装的应用程序的目标。

This is my piece of code. I am getting error "no activity found to handle intent action_all_apps". I can understand that I have not written any class while creating new intent. But, I am not understanding which class to use. Can either of you guide me in achieving my target of "closing the application and show all the installed apps".

推荐答案

试试这个code:

    Intent i = new Intent();
    i.setAction(Intent.ACTION_MAIN);
    i.addCategory(Intent.CATEGORY_HOME);
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(i);
    System.exit(0);

但它是明智的处理您Activites所有onBack pressed()方法YOUE applicatin保持畅通。

But it is advisable to handle all onBackPressed() methods in your Activites to maintain a smooth flow of youe applicatin.

这篇关于Android的API 19:OnBack pressed我想关闭应用程序,并显示所有安装的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆