API Demos _ entry

Source: Internet
Author: User

Demos is based on android 2.3.3 API.
Let's take a look at the ApiDemosApplication. java class, which inherits from the Application and stores some global states. This class will be instantiated when your Application is created,
The class name is the name of the <application> tag of AndroidManifest. xml. For example, in onCreate () in this class:
PreferenceManager. setdefavaluvalues (this, R. xml. default_values, false); this method will fill in the default value from default_values.xml to com. example. android. apis_preferences.xml is included in the default configuration file.
The configuration file is in/data/com. example. android. apis/shared_prefs. According to the official API, This shoshould be called by the application's main activity.
In this way, other activities and services can use the configuration file accordingly.
Next, let's take a look at ApiDemos. java. This class fully applies the AndroidManifest. xml file. First, this class is the program entry, a ListActivity, which will be reused.
In its onCreate () method, the first time path = "" that is, prefix = "", and then look at the getData () method, this method is to fill in the value for this listview, put the entered values in the myData List <Map>:

Intent mainIntent = new Intent (Intent. ACTION_MAIN, null );
MainIntent. addCategory (Intent. CATEGORY_SAMPLE_CODE );
PackageManager pm = getPackageManager ();
List <ResolveInfo> list = pm. queryIntentActivities (mainIntent, 0 );
This code Retrieves all Intent actions in the AndroidManifest. xml file that are ACTION_MAIN and CATEGORY_SAMPLE_CODE. In the list.
The following are some logics that can be understood.
ResolveInfo info = list. get (I );
CharSequence labelSeq = info. loadLabel (pm); obtain the label of all activities. The label format is similar to App/activity/Hello World. If we click App or Activity, we still call ApiDemos. java class, only the content of listview
It's changing. It's in the browseIntent () method.
Each list item is sorted by the ascii code of the first character. You can see in sDisplayNameComparator that the list item can also be filtered by the character you entered.

Author ZircoN

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.