After the Android app is installed, click & amp; quot; Open & amp; quot; (Open) to solve the problem and solution.

Source: Internet
Author: User

After installing the app for Android, click & quot; Open & quot; (Open) to solve the problems and solutions.
MainActivity is as follows:

Package cc. cc; import android. app. activity; import android. content. intent; import android. OS. bundle;/*** Demo Description: ** a problem encountered more than a year ago --->: * 1 after the customer downloaded the application I participated in development from GooglePlay * 2, after clicking install * 3, there are two options at the bottom of the screen: "Open" and "complete" * 4. Click Open * 5 to enter the first Activity. In this case, perform the following operations: for example, enter the text ** 6 on an EditText, press the HOME Key * 7, find the ICON of the application on the desktop, and click it to enter the application. ** the problem occurs at this time, the text originally displayed in EditText is missing ........ * It was strange at the time. after reading the Log, I realized that the previous Activity re-executed onCreate () and onSta *. Rt () and onResume (). ** the customer is holding on to this issue, and I will never give a reasonable explanation. What should I do? * I tested several other apps on GooglePlay and found the same problem. so I told the customer: * this is a problem with the Android system and is difficult to solve. fortunately, the customer has not been entangled in empathy, and this has passed. * But this problem is always in my heart. ** another blog on CSDN recently talked about this issue. I went to stackoverflow to find the answer. * I saw the solution, but to tell the truth, I didn't understand the code. the core sentence: * if (getIntent (). getFlags () & Intent. FLAG_ACTIVITY_BROUGHT_TO_FRONT )! = 0) * I am still confused. I am unwilling to ask a few bloggers, and I have no definite answer. * For the time being, we hope you will have a chance to make it available in the future. ** I am not a code writer, but a code Porter. * The code found from stackoverflow is pasted below. the data source is also provided. ** PS: Google has been unavailable for the past two months. IT is inconvenient for IT staff who often go to some foreign websites to find information. * This may be a small sorrow of Chinese software practitioners. is there any sensitive word in the code of a foreign website ??????????? * ** Reference: * 1 http://www.atlassc.net /? P = 479*2 http://stackoverflow.com/questions/6337217/how-to-return-to-the-latest-launched-activity-when-re-launching-application-afte * 3 http://stackoverflow.com/questions/6356467/activity-stack-ordering-problem-when-launching-application-from-android-app-inst * 4 http://flowercat.iteye.com/blog/380859 * 5 http://blog.csdn.net/nupt123456789/article/details/34415849 * Thank you very much ** note: * The core idea mentioned in document 1 ---> * We need to determine whether the intention is to open a new task or apply the background to the foreground. * if you want to bring the application to the foreground to directly end the Activity, then the Activity displayed is the previously minimized Activity. * The intention of clicking the icon will place the newly started Activity at the top, and the Activity below the top will be the previously minimized Activity. * When the newly started Activity is ended, the previously minimized Activity can be displayed. **/public class MainActivity extends Activity {@ Overrideprotected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); if (getIntent (). getFlag S () & Intent. FLAG_ACTIVITY_BROUGHT_TO_FRONT )! = 0) {finish (); return;} setContentView (R. layout. main) ;}@ Overrideprotected void onStart () {super. onStart (); System. out. println ("---> onStart ()") ;}@ Overrideprotected void onResume () {super. onResume (); System. out. println ("---> onResume ()");}}

Main. xml is as follows:
     
  
 


Related Article

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.