Brief analysis of Wphone, Android's back and home key

Source: Internet
Author: User

Back

In the production of the navigation page, Wphone than Android in the development process is more user-friendly, Microsoft's API has a go back method, you can return to the previous interface, that is, the most recent entries in the home 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 itself in Android also has a stack object to manage the corresponding activity.

But the Android programmer must listen to the corresponding event in the OnKey event to determine if the pressed key is the back key to decide whether to perform a fallback operation.

The program running in Android does not have to be deliberately exited, and when you press the back key of the phone, the Destroy () method of the top activity in the program stack is called by default to destroy the current activity. When this activity is started again by other activity, the OnCreate () method is called again to create, and when all activity in the stack pops up, the application ends. If there is a service in the program and so on, you can listen to the appropriate location under the processing can be.

I believe that the people who read this article are still using Nokia very little, so next through my Nokia phone's various operations to illustrate the difference between the two.

First look at Baidu and first click Back key:

650) this.width=650; "src=" Http://images0.cnblogs.com/blog2015/450484/201508/211926555352003.png "style=" margin:0 px;padding:0px;border:0px, "/> 650) this.width=650; src=" Http://images0.cnblogs.com/blo G2015/450484/201508/211927125975416.png "style=" margin:0px;padding:0px;border:0px; "/>

Wphone doesn't look like android: it just destroys the target activity from the stack, but when you press the right-most menu key (the right side of the home button and a total of three keys below the phone), you can still see the activity. If you click on it, it will go back to the top of the activity and become the current event.

Take a look at the Android phone on the app by clicking the back or home button and then tapping the menu key:

650) this.width=650; "src=" http://images0.cnblogs.com/blog2015/450484/201508/211928433474541.jpg "style=" margin:0 px auto;padding:0px;border:0px; "/>

It is important to note that the activity is regenerated in this process, and the key is that it is null at the time of the savedinstancestate of the OnCreate () method in its startup class (and the home key is different, as explained later).

Instead, you can see that the strategy that Wphone takes is either to cancel the fallback or to exit the application directly.

In fact, this is also reflected in the phone at the bottom of the button design, wphone Three keys are back,home and search, and there is no menu key. Yes, the search button, when I installed beta (voice assist software), click the Search button will pop up the Beta service interface.

Home

As for the home button, Wphone and Android do not have much difference, functionally almost consistent: after clicking directly back to the main interface, the current application is pressed into the activity stack, at this time the Wphone will not force the app to close.

Android Click on the menu button appears in the effect, Wphone will naturally have, otherwise how to close the home button still exist after the activity. In Wphone, if you want to see exactly which application interfaces are still present, you can press and hold the back key. As follows:

650) this.width=650; "src=" Http://images0.cnblogs.com/blog2015/450484/201508/211933528477828.png "style=" margin:0 px;padding:0px;border:0px; "/>

At this point, if you want to turn an app back on, just click it in its interface area, and if you want to close it, click the Circular fork in the upper right corner of the corresponding interface.

Code

As mentioned above, when Android clicks the back and home keys, the process of returning the app to the active state is not the same.

This gives the code that is judged in the OnCreate () method:

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>

1 @Override 2 protected void onCreate (Bundle savedinstancestate) {3 super.oncreate (savedinstancestate); 4 Setcontentv Iew (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 was not null", Toast.length_short). Show (); 10}11}

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>

If you clicked back before, "savedinstancestate is null" will appear on the interface, otherwise "savedinstancestate is not NULL" will be displayed.

Summarize

Finally, let's talk about the layout of Wphone and Android icons. First:

650) this.width=650; "src=" Http://images0.cnblogs.com/blog2015/450484/201508/211944094561772.png "style=" margin:0 px;padding:0px;border:0px; "/>

As you can see, Wphone is used up and down the vertical line, unlike Android is the left and right page flipping style. That said, the more you add, the longer this page will be, and the more you can scroll up and down when you look for an app icon.

It is necessary to say that Android and iOS are similar in the application of icon layout, with the design of the left and right sliding page, while the Wphone and iOS are similar when you wake up or completely shut down the application in the Acticity stack, but the difference between the two is:

1, Wphone is the Chang ' an back key out of all the application interface, iOS is a continuous, fast click the home key two times;

2, Wphone is to click the Close button or swipe down the application interface, iOS is the application interface to swipe up;

However, there are also interesting aspects to note in the size of the icons. Wphone allows the user to customize the size of the icon, and you can drag the icon anywhere on the page to complete the layout you want.

The future of Nokia (or, to be exact, Microsoft Nokia) is a reflection of how the mobile phone landscape of the world is now, if it can be firmly turned to the Android platform.


Brief analysis of Wphone, Android's back and home key

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.