Click on "Open" when Android installs the app and solve the problem

Source: Internet
Author: User

Mainactivity as follows:
Package Cc.cc;import android.app.activity;import Android.content.intent;import android.os.bundle;/** * Demo Description: * * More than a year ago encountered a problem---;: * 1 customers downloaded from GooglePlay I participate in the development of the application * 2 after the download is complete, click Install * 3 after the installation is complete, at the bottom of the screen there are two options "open" and "Done" * 4 Click Open * 5 app into the first Activ ity, at this time simple operation: For example, enter the text on a edittext * 6 Press the Home button * 7 on the desktop to find the app's icon, click to enter the application * * problem occurred at this time, the original display in the EditText text is missing ... * It was so strange It's weird. Read log only to know that the activity has been re-executed OnCreate () and OnStart () and Onresume (). * * Customers hold on to this problem, I have been half a time will not give a reasonable explanation. What should I do? * I tested the rest of the apps on GooglePlay, and I found the same problem. So I said to the client: * This is an Android system problem, it is difficult to solve. Fortunately, the customer is not entangled in understanding, this matter also passed. * But this problem has been buried in my heart. * * * Recently, I saw a blog on csdn to talk about the problem. I went to StackOverflow to find the answer. * See the solution, but honestly, the code I did not understand. The core of this sentence: * if ((Getintent (). GetFlags () & intent.flag_activity_brought_to_front)! = 0) * I am still smattering. Not reconciled to ask a few Bo friends, there is no definite answer. * Temporarily forget, look forward to the opportunity to have a general solution. * * I'm not a writer of code, I'm just a porter of code. * FROM StackOverflow to find the code, I put it below. At the same time, the source of the data. * PS: Has been unable to use Google for the last two months, it is inconvenient for IT staff who often go to some foreign websites for information. * This may be the small sorrow of Chinese software practitioners. Are there any sensitive words in the code of foreign websites??????????? * * * 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 * * Supplementary NOTE: * The core ideas mentioned in information 1---> * We need to judge whether the intention is to open a new task, or to use the background app to refer to the foreground. * If you want to bring the app to the foreground to end the activity directly, then the activity shown is the activity that was previously minimized. * Because the intention of clicking on the icon will place the newly activated activity at the top, the activity below the top is the activity that was previously minimized. * When you end a newly activated activity, you can show the activity that was previously minimized. * */public class Mainactivity extends Activity {@Overrideprotected void onCreate (Bundle savedinstancestate) {  Super.oncreate (savedinstancestate); if (Getintent (). GetFlags () & 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 as follows:
<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android"    xmlns:tools= "http// Schemas.android.com/tools "    android:layout_width=" match_parent "    android:layout_height=" Match_parent "     >    <edittext        android:layout_width= "130dip"        android:layout_height= "40dip"        android: Layout_centerinparent= "true"/></relativelayout>


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.