Implementation principle and code of hidden items in android Setting

Source: Internet
Author: User

We all know that Programmers sometimes spoof things, just like in android, programmers hide this item in setting:

We can find "about mobile phones" in which there is "android version,

When we click "android version", an image (spoof type
This is the 2.3 operating system, but an android logo image will pop up in the 4.0 system.

If you hold down the android logo and do not place it, there will be a lot of android logos in Mobile Animation:

).

Here we will talk about the 2.3 System:

First, find the source code of Settings. Under package/app/Settings/src/com/android/settings, find

The DeviceInfoSettings. java file is related to the code "about mobile phones". It references an xml file in its OnCreate method:

Copy codeThe Code is as follows: addPreferencesFromResource (R. xml. device_info_settings );

So we can find the device_info_settings.xml file:Copy codeThe Code is as follows: <! -- Device firmware version -->
<Preference android: key = "firmware_version"
Style = "? Android: preferenceInformationStyle"
Android: title = "@ string/firmware_version"
Android: summary = "@ string/device_info_default"/>

This is the code that represents the "android version". We can see that its Key isCopy codeThe Code is as follows: firmware_version

Therefore, we can find the referenced code in the java file. There is a public boolean onPreferenceTreeClick method in DeviceInfoSettings. java:Copy codeThe Code is as follows: @ Override
Public boolean onPreferenceTreeClick (PreferenceScreen preferenceScreen, Preference preference ){
If (preference. getKey (). equals ("firmware_version ")){
System. arraycopy (mHits, 1, mHits, 0, mHits. length-1 );
MHits [mHits. length-1] = SystemClock. uptimeMillis ();
If (mHits [0]> = (SystemClock. uptimeMillis ()-500 )){
Intent intent = new Intent (Intent. ACTION_MAIN );
Intent. setClassName ("android ",
Com. android. internal. app. PlatLogoActivity. class. getName ());
Try {
StartActivity (intent );
} Catch (Exception e ){
}
}
}
Return super. onPreferenceTreeClick (preferenceScreen, preference );
}

In this example, you can click "android version" to implement the function.

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.