Data storage and interface display based on Android Application Development (I): android Application Development
Directory structure of the Android Project
- Activity: interface displayed when an application is opened
- Src: project code
- R. java: Resource id of all resource files in the project
- Android. jar: Android jar package. Only Android APIs can be used to import this package.
- Libs: Import third-party jar packages
- Assets: stores resource files, such as mp3 and video files.
- Bin: stores compiled and packaged files.
- Res: stores resource files. Resource IDs are generated for all resource files stored in this folder.
- Drawable: Stores image resources.
- Layout: stores the layout file and assigns the layout file to the activity through the resource id. The layout defined by the layout file is displayed on the page.
- Menu: defines the menu style
- Strings. xml: stores string resources. Each resource has a resource id.
Configuration file for Android (configuration file)
DDMS
- Dalvik debug monitor service
- Dalvik debugging Monitoring Service
Common adb commands: Android debug bridge
- Adb start-server: start the adb Process
- Adb kill-server: kills the adb Process
- Adb devices: view the current device connected to the development environment. This command can also start the adb Process
- Adb install XXX.apk: install apk to the simulator
- Adb uninstall package name: Delete the application in the simulator
- Adb shell: Enter the linux Command Line
- Ps: view running processes
- Ls: view the file structure in the current directory
- Netstat-ano: view the process that occupies the port
Dialing device
Function: enter a number and click the call button to start the application that calls the system to call the number.
1. Define layout 2. Set the button to listen 3. Get the number entered by the user
// Obtain the number entered by the user. First, obtain the EditText et_phone = (EditText) findViewById (R. id. et_phone); String phone = et_phone.getText (). toString ();
4. Call out the number The first method of writing click events
Second
Define an anonymous internal class to implement the onClickListener Interface
Button bt2 = (Button) findViewById (R. id. bt2); bt2.setOnClickListener (new OnClickListener () {@ Override public void onClick (View v) {System. out. println ("second ");}});
Third
Fourth
Set the onClick attribute for the Button node,
android:onClick="click"
Then define the method with the same name as the property value in the activity.
Public void click (View v) {System. out. println ("comment fourth ");}
SMS sender
Function: Enter the number and text message content, click the send button, and call the SMS api to send the text message to the specified number.
1. Define the Layout
2. Click Complete
3. Get the number and content entered by the user
EditText et_phone = (EditText) findViewById(R.id.et_phone); EditText et_content = (EditText) findViewById(R.id.et_content); String phone = et_phone.getText().toString(); String content = et_content.getText().toString();
4. Call the api for sending text messages
// Call the SMS sending api SmsManager sm = SmsManager. getDefault (); // send SMS sm. sendTextMessage (phone, null, content, null, null );
Add permission
<uses-permission android:name="android.permission.SEND_SMS"/>
If the text message is too long, you need to split it.
List<String> smss = sm.divideMessage(content);