Record an "interview" issue with Android development

Source: Internet
Author: User

Pre-order:

3 days ago, lucky to get senior appreciation, and he went to help a Zhuhai local IT company as an interviewer, although so, I myself have not graduated, at best, to see the next. The same day interviewed 13 people, this is only the morning, I flashed in the afternoon. In the part of the written test, I set up a relatively simple and common Android page jump problem , of course, to the other "big guy" first review.

Problem prototypes:

Existing 3 pages, a page each initialization will request a network data, a always use StartActivity (Intent), jump to B,b page is the data editing page, it has 3 buttons, a Click Always return a, an upload data, the last click to jump to the C page, The C page is responsible for selecting images or videos, and the C page allows only one button to be set.

Now you need to set the A->b->c->b->a's jump logic correctly, and the reason for the minimum number of requests for the network.

N answers received (core below), reason omitted (not remember ...) :

1,a jump to B,b use StartActivity () jump to C,c after selecting the data, click the button with StartActivity () with data jump back b,b using startactivity () jump back to A;

This answer, needless to say, the drawback is a just when the app was initialized to request a network, in the final jump was initialized once, and, B also in C jump is more initialized once, this is the blind use of statryactivity, the author development experience is less. Although I am also a novice, this still knows.

2,a jump to B,b using startactivity () jump to C,c after selecting the data, click the button with StartActivity () with data jump back to B,b using finish () to jump back to a.

Dead loop mode, this direct pass off.

3,a jump to B,b use Startactivityforresult () jump to C,c after selecting the data, click the button to use Finish () with data jump B,b using finish () back to a.

The perfect pattern in my heart.

4, first declare a global static Boolean variable. A jump to B,b using startactivity () jump to C,c after selecting the data, the global Boolean to True, click the button to use the finish () jump b,b in the Onresume to judge this Boolean, there is data to do the corresponding control operation, otherwise do not operate, Back a uses finish ().

This kind of answer is also feasible, the author of the activity of life cycle more understanding, the disadvantage is the sacrifice of space, not widely used.

.....

Conclusion:

This is a relatively basic problem that requires a certain amount of experience in actual combat development and an understanding of the activity life cycle in order to answer better, above all a personal point of view.

Record an "interview" issue with Android development

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.