Android Life cycle

Source: Internet
Author: User
<span id="Label3"></p><p><p>1. Activity Jump</p></p><pre><pre><span style="color: #000080; font-weight: bold;">New Intent (mainactivity. <span style="color: #000080; font-weight: bold;"> This,nextactivity. <span style="color: #000080; font-weight: bold;">class);<br></span></span></span><span style="background-color: #e4e4ff; color: #000000;">StartActivity (intent);</span></pre></pre><pre><pre></pre></pre><p><p>Jump to Nextactivity</p></p><p><p>2, with Data jump</p></p><pre><pre><span style="color: #000080; font-weight: bold;">New Intent (mainactivity. <span style="color: #000080; font-weight: bold;"> This,nextactivity. <span style="color: #000080; font-weight: bold;">class);<br>Intent.putextra (<span style="color: #008000; font-weight: bold;">"name",<span style="color: #008000; font-weight: bold;">"yinting");<br><span style="color: #000080; font-weight: bold;">New Bundle ();<br>Bundle.putint (<span style="color: #008000; font-weight: bold;">"age",<span style="color: #0000ff;">22);<br>Bundle.putchar (<span style="color: #008000; font-weight: bold;">"bood",<span style="color: #008000; font-weight: bold;">' b ');<br>Intent.putextra (<span style="color: #008000; font-weight: bold;">"bundle", bundle);<br><span style="color: #000080; font-weight: bold;"><span style="color: #0000ff;">StartActivity (intent);</span></span></span></span></span></span></span></span></span></span></span></span></span></pre></pre><p><p>3. Receive return value jump</p></p><pre><pre> Intent Intent = <span style="color: #000080; font-weight:bold;">new Intent (mainactivity.<span style="color: # 000080; font-weight:bold; ">this,nextactivity. <span style="color: #000080; font-weight:bold; >class); <br> Intent.putextra (<span style= " color: #008000; font-weight:bold;"> "name", <span style="color: #008000; font-weight:bold; "> "yinting"); <br> Bundle bundle = <span style="color: #000080; font-weight:bold;">new Bundle (); <br> Bundle.putint (<span style="color: #0000ff;" "age", <span>22); <br> Bundle.putchar (<span style="color: #008000; font-weight:bold;"> "bood", <span style="color: #008000; font-weight:bold;" ' b '); <br> Intent.putextra (<span style="color: #008000; font-weight:bold;" "bundle", bundle); <br> Mainactivity. <span style="color: #000080; font-weight:bold;">this.startactivityforresult (intent, <span style="color: #0000ff;">1); <br> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span> </pre></pre><p><p><span style="background-color: #000000; font-family: Microsoft YaHei; color: #000000; font-size: 16px;"><span><span style="background-color: #ffffff;">The method must be Onactivityresult and Replicated.</span></span></span></p></p><p><p></p></p><pre><span style="color: #000080; font-weight: bold;"><span style="color: #000080; font-weight:bold;">protected void Onactivityresult (<span style="color: #000080; font-weight:bold; ">int requestcode, <span style="color: #000080; font-weight:bold;">int resultcode, Intent data) {<br> <span style="col Or: #000080; font-weight:bold; ">super.onactivityresult (requestcode, resultcode, data); <br> <span style="color: #000080; font-weight:bold;">if (requestcode==<span style="color: #0000ff;">1&& Resultcode==<span style="color: #0000ff;">1001) {<br> String name= data.getstringextra (<span style="color: #008000; font-weight:bold; "> "name"); <br> Toast. <span style="font-style:italic;">maketext (mainactivity.<span style="color: #000080; font-weight:bold;"> This,<span style="color: #008000; font-weight:bold;"> "---->" +name,toast.<span style="font-style:italic; Color: #660e7a; font-weight:bold; ">length_long). Show (); <br> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span></span><span style="color: #000080;"><span style="color: #000080;"><span style="color: #000080;"><span style="color: #000080;"><span style="color: #000080;"><span style="color: #000080;"><span style="color: #0000ff;"><span style="color: #0000ff;"><span style="color: #008000;"><span style="color: #000080;"><span style="color: #008000;"><span style="color: #660e7a;"> }</span></span></span></span></span></span></span></span></span></span></span></span><span style="color: #000080;"><span style="color: #000080;"><span style="color: #000080;"><span style="color: #000080;"><span style="color: #000080;"><span style="color: #000080;"><span style="color: #0000ff;"><span style="color: #0000ff;"><span style="color: #008000;"><span style="color: #000080;"><span style="color: #008000;"><span style="color: #660e7a;"><br><br><span style="background-color: #ffffff; font-family: Microsoft YaHei; color: #000000; font-size: 16px;">nextactivity with data returned at the End. </span></span></span></span></span></span></span></span></span></span></span></span></span><span style="color: #000080; font-weight: bold;"><span style="color: #000080; font-weight: bold;"><span style="color: #000080; font-weight: bold;"><span style="color: #000080; font-weight: bold;"><span style="color: #000080; font-weight: bold;"><span style="color: #000080; font-weight: bold;"><span style="color: #0000ff;"><span style="color: #0000ff;"><span style="color: #008000; font-weight: bold;"><span style="font-style: italic;"><span style="color: #000080; font-weight: bold;"><span style="color: #008000; font-weight: bold;"><span style="font-style: italic; color: #660e7a; font-weight: bold;"><br><br></span></span></span></span></span></span></span></span></span></span></span></span></span></pre><p><p></p></p><pre><pre>Intent intent=<span style="color: #000080; font-weight: bold;">New Intent ();<br>Intent.putextra (<span style="color: #008000; font-weight: bold;">"name",<span style="color: #008000; font-weight: bold;">"yangyi");<br>Nextactivity. <span style="color: #000080; font-weight: bold;">This.setresult (<span style="color: #0000ff;">1001,intent);<br>Nextactivity. <span style="color: #000080; font-weight: bold;">this.finish ();</span></span></span></span></span></span></pre></pre><p><p><strong><span style="font-family: Courier New; color: #0000ff;">4. Android Life cycle</span></strong></p></p><p><p><strong><span style="font-family: Courier New; color: #0000ff;"></span></strong></p></p><p><p>5. Activity Site Protection</p></p><p><p></p></p><p><p>Android Life cycle</p></p></span>

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.