Android Entry mark (re-stencil)

Source: Internet
Author: User
Tags event listener gettext

Directory structure for Android projects (Eclipse edition)

  src: Project Source code folder

  R.java: resource ID for all resource files in the project, never modify

  Android.jar: Android jar package, import this package to use Android API

  Libs: storing third-party jar packages

  assets: Resources folder, storage of video or music and other large resource files

  bin: Store compiled and packaged files

  res: Resource folder, all resources in this folder, there will be resource ID, read through the resource ID can be read. Cannot appear in resource ID in Chinese

     drawable: Storing picture resources

    Layout : layouts folder, save layout file, all layout files in Android are XML files

    Menu: Menus configuration folder, save menu configuration file, decide menu style

    Values

       Strings: string resource file that defines the string resource's

       dimens: length resource file, used to define length resources

      Style : Styles and theme resource files

Android configuration file (manifest file)

The package name specified in the manifest file as the application's unique identification in the system, such as package= "Org.eniac.helloworld" , the file generated by the app will be stored under this path: data/data/ Org.eniac.helloworld

Specify the version number of the app with Versioncode

All four components of Android need to be configured in the manifest file before use

Activity with the following sub-tabs is the entry activity

< Intent-filter > <  android:name= "Android.intent.action.MAIN"/><   Android:name= "Android.intent.category.LAUNCHER"/></  Intent-filter>

Installation path

System Application Save path: System/app

Third-party app save path: Data/app

data/data/Package Name folder: A dedicated space provided by the system for each application

DDMS (Dalvik Debug Monitor Service,dalvik Debug Monitoring service)

ADB (Android Debug Bridge), which is the Android debug bridges, is used to establish the connection between the development environment and Android devices. The usual ADB directives are as follows:
    

    adb start-server: start adb process

    adb kill-server: kill ADB process

    adb devices: View the devices currently connected to the development environment and this command can also start the ADB process

    adb install xxx.apk: installing apk to Simulator

    adb Uninstall Package name: Remove an app from the emulator

    adb Shell: Enter the Linux command line

    PS: lists all the processes that are running on the current system

    ls: lists all files and folders in the current directory

    Netstat-ano: Viewing the port occupancy of the system

Phone Dialer

Function: The user enters a number, clicks the Dial button, starts the system to call the application to call out the number

1 Defining layouts

1.1 The component must be set to a wide height, otherwise it cannot be compiled

Android:layout_width= "Wrap_content" android:layout_height= "Wrap_content"

1.2 If you want to manipulate a component in Java code, the component needs to set the ID so that it can be obtained by ID in the code

Android:id= "@+id/et_phone"

2 Setting the button to tap listen

Button Bt_call = (button) Findviewbyid (r.id.bt_call);    Get the button object by ID bt_call.setonclicklistener (new MyListener ());     Setting event listeners for a button    

3 Get the number entered by the user

// Get the Input box component first, and call the GetText () method EditText Et_phone == Et_phone.gettext (). toString ();

4, call out the numbers.

4.1 Android system is based on the action mechanism to invoke the application of the system. You tell the system what you want to do, and the system will give you an app that can do the action, and if it doesn't, it throws an exception.

4.2 Setting actions, telling the system through intent

// Create an Intent object first New Intent (); // set up actions, call intent.setaction (Intent.action_call); Intent.setdata (Uri.parse ("Tel:" + phone)); // the intention to tell the system startactivity (intent);

4.3 Adding permissions

<android:name= "Android.permission.CALL_PHONE"/>

Four ways to click events

First Kind

Defines a MyListener class implementation Onclicklistener interface (implements event listener using an inner class)

Button BT1 = (Button) Findviewbyid (R.ID.BT1); Bt1.setonclicklistener (new MyListener ());

The second Kind

Defines an anonymous inner class implementation Onclicklistener interface (anonymous inner class implements event listener)

Button BT2 = (Button) Findviewbyid (R.ID.BT2); Bt2.setonclicklistener (new  Onclicklistener () {@ Overridepublicvoid  OnClick (View v) {System.out.println ("second type");}});

Third Kind

Let current activity implement Onclicklistener interface (current Activity class as event listener)

Button BT3 = (Button) Findviewbyid (R.ID.BT3); Bt3.setonclicklistener (this);

Fourth type (common)

To set the OnClick property on a button node

android:onclick= "click"

Then define a method with the same name as the property value in activity

 Public void Click (View view) {System.out.println ("fourth type");}

SMS Transmitter

Function: User input number and text message content, click the Send button, call SMS API to send SMS to the specified number

1 Defining layouts

Tips for entering boxes

android:hint= "Please enter Number"

2 Complete Click events

2.1 Set the OnClick property to the button component first

android:onclick= "Send"

2.2 Define this method in activity

 Public void Send (View v) {
}

3. Get the number and content entered by the user

EditText Et_phone == = = Et_content.gettext (). toString ();

4. Call the API to send SMS

Smsmanager sm = Smsmanager.getdefault ();    // call API to send SMS NULL NULL null); // Send SMS

Add permissions

<android:name= "Android.permission.SEND_SMS"/>

If the text message is too long, you need to split

list<string> SMSS = sm.dividemessage (content);

Android Entry mark (re-stencil)

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.