In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to analyze the Back and Home keys of WPhone and Android? aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Back
In terms of navigation page creation, WPhone is more user-friendly than Android in the development process. Microsoft API has a Go Back method that allows you to go back to the previous interface, the latest entry in the Back stack. If there are no entries in the Back stack, this method throws an exception, so always check the Can Go Forward before calling this method. The Activity in Android also has a stack object to manage the corresponding Activity.
However, the Android programmer must listen to the corresponding event in the onKey event to determine whether the pressed key is the back key to decide whether to perform the fallback operation.
The program running in Android does not need to exit deliberately. When the Back key of the phone is pressed, the system will default to call the Destroy () method of the top Activity in the program stack to destroy the current Activity. When this Activity is started by another Activity, the OnCreate () method is called again to create it, and when all the Activity pops up in the stack, the application ends. If there is something like Service in the program, you can listen in the right place and deal with it.
Next, I use screenshots of various operations of my Nokia phone to illustrate the difference between the two.
WPhone is not like Android: it just destroys the target Activity from the stack, but you can still see the Activity when you press the rightmost menu key (to the right of the Home key, a total of three keys below the phone). If you click on it, you will go back to the front of Activity to become the current activity.
It is important to note that Activity is regenerated during this process, and the key is that the value of SavedInstanceState in the onCreate () method of its startup class is null at this time (unlike the Home key, which will be explained later).
As you can see from the figure, the strategy adopted by WPhone is to either cancel the fallback or simply exit the application.
In fact, this is also reflected in the design of the buttons at the bottom of the phone. The three WPhone keys are Back,Home and Search, and there are no menu keys. Yes, it's the search button, and when I install Beta, clicking the Search button will pop up the Beta service interface.
Home
As for the home button, there is not much difference between WPhone and Android, and the function is almost the same: click and go straight back to the main interface, push the current application into the Activity stack, and the WPhone will not force the app to be closed.
The effect of Android clicking on the menu key will naturally be found in WPhone. Otherwise, how to close the Activity that still exists after clicking the Home button. In WPhone, if you want to see which application interfaces still exist, long press the Back key. The effect picture is as follows:
At this point, if you want to reopen an application, just click in its interface area; if you want to close it, click the circular fork in the upper-right corner of the corresponding interface.
Code
As mentioned above, Android's process of getting the app back active after clicking the Back and Home keys is not the same.
Here is the code to judge in the onCreate () method:
1 @ Override 2 protected void onCreate (Bundle savedInstanceState) {3 super.onCreate (savedInstanceState); 4 setContentView (R.layout.activity_main); 5 if (savedInstanceState = = null) {6 Toast.makeText (this, "savedInstanceState is null", Toast.LENGTH_SHORT). Show (); 7} 8 else {9 Toast.makeText (this, "savedInstanceState is not null", Toast.LENGTH_SHORT). Show (); 10} 11}
If you clicked Back before, "savedInstanceState is null" will be displayed on the interface, otherwise "savedInstanceState is not null" will be displayed.
Summary
WPhone is arranged vertically up and down, unlike the left and right page flip style of Android. That is, the more you add, the longer the page will be, and you can only scroll up and down when looking for the application icon.
It is necessary to say again that Android and IOS are similar in the layout of application icons, using the design of sliding left and right pages; while when re-awakening or completely shutting down applications in the Acticity stack, WPhone and IOS are similar, arranging the application interface left and right, but the difference is:
1. WPhone is the Changan back key that jumps out of all the application interfaces, and IOS clicks the Home key twice in a row and quickly.
2. WPhone clicks the close button or slides down the application interface, while IOS slides the application interface upward.
However, there is also an interesting aspect, note the size of the icon in the image above. WPhone allows users to customize the size of the icon, and you can drag the icon on the page to complete the layout you want.
This is the answer to the question about how to analyze the Back and Home keys of WPhone and Android. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.