Malicious targeting Android (not to mention, toxic)

Source: Internet
Author: User

Malicious targeting Android (not to mention, toxic)

I think there is a big flaw in the android system. This is the big failure that causes the card of the android system to stop.

This is the design of the activity.

Android's design principle for activity is: it must be runtime independent.

You cannot directly create an activity and start it. It must be done by the system for you. To start the activity, you must use an Intent to request help from the system. Therefore, you must declare every activity in the app in the manifest file. If you have multiple activities declared as start-up and specified intent-filter, each activity may become the portal of your app.

Since each activity may become an entry, each activity must be independent of function and self-satisfied. That is to say, the process concept is relaxed. If an activity is destroy, even if its app process does not exit and a new activity is started, the app of the activity exits.

However, the ideal is too plump, and the reality is nothing more than you. How many people can have such communist thoughts and energy to build an imaging system for every activity, and call and send text messages to such apps? Most of the activities are used internally, and it is too difficult for each activity to be independent, especially when data is shared between activities in the app, in accordance with its principles, data should be placed in the additional intent data, start the next activity with startActivityForResult (), and receive the data returned by the next activity in onActivityResult, however, How easy is it to make global static data?

Is this design too much? You can kill activity or process unrelated to the front-end app, but how can you kill activity in the front-end app? Instead of killing the system, it is better to let programmers kill it on their own. Besides, if the system memory is unable to maintain the normal operation of an app, is this app too poorly designed?

There is another chaotic situation: the navigation bar is promoted in the latest android system (do you want to learn from Apple and save a key ?), Therefore, the return button is available in the navigation bar. However, when B is started from Activity A and then the return button is clicked on the navigation bar of B to return A (in the manifest file, A is specified as B's father ), in fact, A is not the original A, but creates A new one. Is it too boring? In this case, onActivityResult () in A will never be executed! Therefore, you must note that the return button on the navigation bar is different from the return key of the device... Let's talk about it three times!

In addition, the android development documentation clearly states that if the background thread is enabled in the activity, it should be disabled in onDestroy. Okay. Generally, an app is operated by navigation multiple pages. That is to say, when a multi-threaded activity is switched between hiding and display, it must be switched ON and OFF multiple threads continuously?

Is there a way to solve this problem? Yes! You can use another independent and self-fulfilling component: service. Using the service for background transactions does not affect background tasks when the activity is explicit or hidden, but communication between the activity and the service is required, which is troublesome.

But there are always better solutions than none!

This design principle has brought about a more chaotic issue of activity lifecycle management! Let's take a look at this figure. How terrible is the lifecycle of the activity!

See the following figure:

(Lifecycle of an Activity <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4NCjxwPri01NO + response/response + srHvfS4 + m9uUGF1c2UoKbXEo6zL + response/ix8KGj1eK + response + a/qL + response/response + release/release + rG + release/release + thY3Rpdml0ebrcz + release/release + release/ySU9T0afSu8/release + 3 ceww + bL + b2yo6y/release + rG + w7vT0M3Ls/conflict + zzNTZv6rG9KO/conflict/tvhJT1PE2KO/conflict + conflict/conflict + sLrtffV + conflict/y + zdK71rG05tTao6y2 + examples/ydLUyMPL/examples + MfSxOPSsr/J0tS + examples/examples + examples/3By8bBxLvQ/deqyrgjr1_sr + 31 sfpv/examples + samples/samples + zcrHz + vIw8Tj1eLR + release/release + DQrK18/Ivs3Kx7C0yc/release + release/Qp7XE1 + m8/release + release = "brush: java; "> android:configChanges=“orientation|keyboardHidden”

Then respond to the callback method in the activity:
public void onConfigurationChanged (Configuration newConfig) 

In the new version, we hope that andorid can regain the concept of a process, so that everyone can freely decide whether to make the activity independent of the runtime, and further learn from IOS, change the pause of the activity to "Enter the background", and change the resume to "become the foreground". In addition to the most important create and destroy in the life cycle, change the name of the remaining items and remove them. So it is good for us. It is excellent anyway.

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.