Android NetEase Cloud class first week note 16/5/10

Source: Internet
Author: User

Android NetEase Cloud class first week notes  
First week of the main task review, the first is the Android environment to build and install the Android Studio software to use. The second is the construction of the Android Hello Word project, the other features of the project include the basic use of button functions, such as page jump, toast,intent, and so on, and I think the most important thing is the activity of life activities of the explanation, Although the teacher in the classroom is just a simple display of the life cycle of several content, but I think if you want to play a good activity, the life cycle of this piece must be understood and mastered, nonsense not much to say directly into the topic. Android Build Environment 1.Android SDK 2.java SDK 3.Android Studio installation. This does not explain the download and installation process, tell me about my download and installation of the problem, I have not found any major problems in the SDK, and then found that there is a problem when running the Android virtual machine, first of all, when running the android-x86 virtual machine appears Vt-x is disabled in the BIOS error, which appears mainly in the BIOS of the computer, the Intel virtual technology in the BIOS does not open The workaround is: Turn on your computer BIOS, find security,and then pressEnterKey , scroll to"Virtualization", and then pressEnterkey to set it to Enabled. Next, the main topic of the course, first of all, it is important to mention the issue of data transmission. The teacher is a little complicated in class. I have a simple understanding here. The first step is to pass data (such as a string) to the next activity. Button.setonclicklistener (New View.onclicklistener () {@Override public void OnClick (View v) {Intent Intent        = new Intent (firstactivity.this,newactivity.class);        String data = "Hello newactivity";    Intent.putextra ("Extra_data", data);//carry the string to the third page startactivity (intent); }});
Here is the main use of the Inter.putextra method, the content of the transmission is data, "Extra_data"This parameter is a key that is used when a value is taken in the new activity. And then we're inThe contents of the newactivity are removed. Intent Intent =getintent (); String data = Intent.getstringextra ("Extra_data"); LOG.D ("newactivity", data);
The idea is to use the Getintent () method to remove the intent, call the Getstringextra () method to take out the content, good idea is so simple. So how do you return data to the previous activity? In fact, the core idea is to useInter.putextra method, but where to use, of course, in the newactivity inside, then the specific code where best to put. To return to the last activity, we use the phone when the return button is generally used, so theInter.putextra put in the onbackpressed () best, press the Back button when the run, nonsense not to say the code attachedButton.setonclicklistener (New View.onclicklistener () {@Override public void OnClick (View v) {Intent Intent        = new Intent (firstactivity.this,newactivity.class);        String data = "Hello newactivity";    Intent.putextra ("Extra_data", data);//carry the string to the third page Startactivityforresult (intent,1); }});First, the Startactivityforresult (intent,1) is used here, where 1 is the request code, which is used when the firstactivty receives the data. @Overridepublic void onbackpressed () {Intent Intent = new Intent ();    Intent.putextra ("Data_return", "firstactivity");    Setresult (result_ok,intent); Finish ();}rewrite the good onbackpressed () f French side. Setresult (result_ok,intent), RESULT_OK is the result of processing, but also really accept the time, that is, the teacher's ResultCode@Overrideprotected void Onactivityresult (int requestcode, int resultcode, Intent data) {switch (Requestcode) {                 Case 1:if (ResultCode = = RESULT_OK) {String returneddata = Data.getstringextra ("Data_return");            LOG.D ("Firstactivity", returneddata);        } break; Default:}}Well, there's something going on with the data.
life cycle of activities  public class MyActivity extends Activity {
@Override public void OnCreate (Bundle icicle) {super.oncreate (icicle);//This law has been used many times, it is called when the activity is created, as long as it is used to load layouts and bind events } @Override public void OnStart () {Super.onstart ();//When the activity is called by invisible visibility} @Override public void OnR Estart () {Super.onrestart ();//From Stop state to run State} @Override public void Onresume () {super.onresume ();//Activity Place When running state} @Override public void OnPause () {super.onpause ();//The system is called when resuming and starting another activity, and some key data is saved in the background} @Overrid e public void OnStop () {super.onstop ();//The activity is called at completely invisible time, and OnPause is different, if the new activity is some dialog box will not be used onStop}
@Override public void OnDestroy () {//activity becomes destroyed State Super.ondestroy (); }
}  now to say the next side of the problem, the first is that we have the most previous lessons with one activity through the button to go to another interface using the method, the first is the page is active, that is, in Onresume () here, The page runs OnPause (), and OnStop () when the button is pressed to convert the page, and Onrestar (), OnStar (), and Onresume () are called when the return key is pressed. we see on the left, when our new activity needs to occupy a lot of memory, when the new activity is called, this is the page will call Onpause,onstop, OnDestroy. Because the new activity requires a lot of memory, this activity can only be destroyed to prevent the memory from being affected by the new activity, and when the activity is rerun, the Oncreat and OnStar methods, the left line, are called again. so from OnPause to Onresume, it is when we use the dialog box when the call, the specific process, try to put it. Okay, here's the first note.

Android NetEase Cloud class first week note 16/5/10

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.