Address: http://blog.csdn.net/you_and_me12/article/details/7284749
Recently I am working on my own applications. I need to use it to determine whether it is the current desktop or not.
I have referenced some articles, some of which have been mentioned but are not clear.
The code in this article has been put into practice and is for reference only!
1. First, obtain desktop applications (original system applications, go desktops, etc)
Analysis: 1) these applications will contain: "
The example in this article describes how Android can determine whether the interface is now a home desktop. Share to everyone for your reference. The implementation methods are as follows:
/**
* Get the application package name that belongs to the desktop
* @return return a list of strings containing all package names
/private list
Analysis:
1 If you want to judge the current interface, it
When the Android device presses the Home key, it will automatically switch back to the desktop. In fact, the implementation method is very simple. Because the Launcher captures the action of the Home key, we can directly send an Intent to the Launcher. The Code is as follows:
Intent intent = new Intent (Intent. ACTION_MAIN );
Intent. setFlags (Intent. FLAG_AC
Paste this code into super.oncreate (savedinstancestate); AfterRemenber processif (!this.istaskroot ()) {//determines if the activity is the source activity of the task space, "non" means that it is re-instantiated by the systemIf you put it in launcher activity, you can return it directly.Intent mainintent=getintent ();String action=mainintent.getaction ();if (Mainintent.hascategory (intent.category_launcher) action.equals (Intent.action_main)) {Finish ();Return;//finish () After the activity
In Android Application Development, we do not want users to directly press the Back key to exit the Activity, but hide the application to the background, similar to pressing the Home Key.
The following provides sample code. For more information, see.
1 public boolean onKeyDown (int keyCode, KeyEvent event) {2 if (keyCode = KeyEvent. KEYCODE_BACK) {3 Intent intent = new Intent (Intent. ACTION_MAIN); 4 inte
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.