ArcGIS API for Android case study 4

Source: Internet
Author: User
Insert some basic Android concepts

It is required to insert an advertisement in this article, and now it is inserted. Advertisements are equally brilliant. Do not go away.

Figure 9 "Hello World" project directory structure

Expand the "agssamplehelloworld" project from eclipse, and we can see the directory structure shown in Figure 9. In this directory structure, the most eye-catching is the "src" directory and "helloworld. Java", which makes us immediately realize that this is a Java program. Yes, although the Android system is based on the Linux kernel, it uses the Java language to develop applications in Android. the bytecode compiled by Java code will run in a virtual machine in Linux, this virtual machine is named Dalvik [1].

There are two configuration files under the root directory of the project: "Default. properties" and "androidmanifest. xml ". These two configuration files are in such a "root" position, of course, the role of the entire project has outline, first look at this "default. properties, open only one line of actual content (and comment on many lines ):

Target =Android-8

From the comments of this file, you do not need to modify this file or get much information from it. This file only tells the android compilation system, the target platform of this project is "Android-8", that is, Android 2.2.

Figure 10 Relationship Between Android platform version and API version

However, "androidmanifest. xml" is different. You can see from the name that this is the list file of the android project. You can directly open it in a text editor as follows:

& Quot; 1.0 & quot; encoding ="UTF-8"?>

Http://schemas.android.com/apk/res/android"

Package ="Com. ESRI. ArcGIS. Android. Samples"

Android: versioncode ="1"

Android: versionname ="1.0">

"@ Drawable/icon" Android: Label ="@ String/app_name">

". Helloworld"

Android: Label ="@ String/app_name">

"Android. Intent. Action. Main"/>

"Android. Intent. Category. launcher"/>

"Android. Permission. Internet">

Android: Name ="Android. Permission. write_external_storage">

Android: Name ="Android. Permission. access_fine_location">

"7"/>

Below this configuration file, there are some It contains the permissions required for the normal operation of the project. For example, an online map is displayed when "agssamplehelloworld" is running. Obviously, it requires an Internet connection, you need to configure "android. permission. internet. In this way, when the application is installed, Android will ask the user: "Do you allow this application to access the Internet ?", If the user permits it, your application can get the map normally. Of course, don't worry about writing configuration files. The Android development tool provides the "android manifest Editor" to help you easily edit configuration files, for example, the user permission can be modified in 11.

Figure 11 configure project permissions using the android development plug-in

The configuration file contains the description of the components contained in the application. First, let's pick out the attribute values of the element itself:

"@ Drawable/icon" Android: Label ="@ String/app_name">

"@ Drawable/icon" is obviously the icon of this program, but which image does it correspond? This will continue to look at the directory structure of the current project. There is a "res" folder under the project directory, which mainly stores various resources of the application, the directories prefixed with "drawable-" are the directories for storing images, different directories are followed by different contents such as "hdpi" [2], "mdpi" [3], and "ldpi" [4, these directories correspond to different images on screens of different sizes, because small screens may only require small images, while large screens may require larger and finer images.

Figure 12 Resources under the res directory

"@ String/app_name" corresponds to a string, which is "strings. as defined in the XML file, Opening this file is as follows:

& Quot; 1.0 & quot; encoding ="UTF-8"?>

"Hello"> Hello world, helloworld!

"App_name"> helloworld sample

Presumably, after the application runs, the "helloworld sample" line should be displayed on its title bar, right.

Why do we configure some content in some directories and XML files so that the android program can know where to obtain real resources? Because the android development tool will help us generate a "R. java "source file, which defines a class named" r ". Different static variables in this class indicate different locations of various resources. As you can see later, in the Java code of the program, we can directly use the R. xxx. xxx refers to a resource.

Figure 13 automatically generated R. Java

There are also elements in the list file, which correspond to the activity in the android program. Because the ad has been inserted for a long time, this content will be available for future reference. However, at least you should have some knowledge about the content contained in an android project?

[1] http://zh.wikipedia.org/zh-cn/dalvikvm

[2] high-resolution images, such as WVGA (480x800) and fwvga (480X854)

[3] medium-resolution images, such as hvga (320x480)

[4] low-resolution images, such as qvga (240x320)

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.