First, Android basic knowledge
1. Write 10 simple Linux commands
mkdir Create folder rmdir Delete folder rm Delete file MV Move file CP Copy file Cat view file tail view file tail More paging view file CD switch current directory LS list file list reboot Restart date display Date C Al Display Calendar
PS View System process equivalent to Windows Task Manager ifconfig Configuring the network
2. Write out the directory structure of Android project
Android. Jar Dependent Android SDK assets resource file bin generated bytecode apk in this libs dependent jar and so res resource file
drawable drawable-hdpi Layout
Menu values
Androidmanifest.xml
Project.Properties
3, what is the ANR how to avoid it?
On Android, if your application has been unresponsive for a while, the system will show the User a dialog box called the application unresponsive (anr:application not responding) dialog box. Users can choose to keep the program running, but they do not want to process the dialog box every time they use your application. Therefore, it is important to design the response performance in the program so that the system does not display
ANR to the user.
Different components occur when the ANR time is not the same, the main thread (Activity, Service) is 5 seconds, Broadcastreceiver is 10 seconds. Solution: Put all the time-consuming operations, such as network access, Socket communication, querying a large number of SQL statements, complex logical computations, and so on in sub-threads, and then update the UI through Handler.sendmessage, Runonuitread, Asynctask, and so on. In any case, make sure the user interface is working smoothly. If the time-consuming operation requires the user to wait, the progress bar can be displayed on the interface.
4, talk about the advantages and disadvantages of Android
Advantages:
1, open, open source, free, customizable
2. Break free from operator's bondage
3. Rich Hardware Selection
4. Developers who are not subject to any restrictions
5, seamless combination of Google application shortcomings:
1, security issues, privacy issues
2, the homogeneity of serious
3. Carriers still have an impact on Android phones
4, the serious of the cottage
5, excessive reliance on developers, lack of standard configuration
5. What is the maximum number of bytes in a text message?
In China, the three major carriers usually have Chinese 70 (including punctuation) and 160 in English. How long does it take to see the operator type for other foreign operators?
Inside Android is a specific text message using the following code to determine how many bytes.
ArrayList android.telephony.SmsManager.divideMessage (String text)
7, how to determine whether there is an SD card?
Use the following methods:
Environment.getexternalstoragestate (). Equals (environment.media_mounted)
Returns true if there is a sdcard, if return false is not.
8, the process of DVM and the process of Linux, is the application process the same concept?
DVM refers to Dalvik virtual machines. Each Android application has a separate instance of the Dalvik virtual machine, and the application runs in its own process. And each DVM is a process in Linux, so it can be approximated as the same concept.
What is Android Dvm:dalvik is Google's own Java virtual machine designed for Android platforms, each Dalvik application executed as a standalone Linux process. A standalone process can prevent all programs from shutting down when the virtual machine crashes.
The difference between Dalvik and Java virtual machines
Dalvik mainly includes the completion of object lifecycle management, stack management, thread management, security and exception management, as well as garbage collection and other important functions.
Dalvik is responsible for process isolation and thread management, and each Android application will have a standalone Dalvik virtual machine instance at the bottom, and its code can be executed under the virtual machine interpretation.
Unlike Java virtual machines running Java bytecode, the Dalvik virtual machine runs its proprietary file format, Dex
The Dex file format reduces the overall file size and improves the class lookup speed of I/O operations.
The Odex is designed to further improve performance during operation and further optimize the Dex file.
All Android apps have threads that correspond to one Linux thread, so virtual machines can rely more on the operating system for thread scheduling and management
Mechanism
- There is a special virtual machine process Zygote, which is an incubator of virtual machine instances. It will be generated when the system starts, it will complete the initialization of the virtual machine, library loading, prefabricated class library and initialization operations. If the system needs a new instance of the virtual machine, it will quickly replicate itself and provide the system with the fastest data. For some read-only system libraries, all virtual machine instances share a memory area with Zygote.
What is the difference between a 9.Android program and a Java program?
Android app developed with Android SDK, Java program developed with JAVASDK.
Android SDK refers to most of the Java SDK, a few parts are discarded by the Android SDK, such as the interface section, java.awt swing package In addition to Java.awt.font is quoted, others are discarded, on the Android platform cannot be used in development. Android SDK Add tool jar HttpClient, pull OpenGL
10. After starting the application, change the system language, the language of the application will change?
This is generally not possible, it is generally necessary to restart the application in order to change the application language. However, if the application is internationalized, it will be supported if not
It is useless to have the processing that system language again changed.
11, please introduce the role of ADB, DDMS, AAPT
ADB is an Android Debug bridge, the Android debugger means that the DDMS is Dalvik debug Monitor Service,dalvik Tune
Monitoring services. AAPT is the Android Asset packaging Tool, under the Build-tools directory of the SDK. The tool can be viewed, created, updated in zip format with document attachments (Zip, jar, apk). You can also compile the resource file into a binary file, although we have not used the tool directly, but the development tool will use this tool to package the APK file to form an Android application.
Android's main debugging tool is ADB (Android Debuging Bridge), Ddms is a graphical tool based on ADB. ADB, which is a command-line tool. The DDMS function is the same as the ADB, except that it has a graphical interface. For people who don't like the way they work today.
is a good choice.
12. The difference between DDMS and TraceView
DDMS Original Intent is: Davik Debug Monitor Service. Simply put, DDMS is a program execution viewer, where you can see information such as threads and stacks, and TraceView is a program Performance Analyzer. TraceView is part of the DDMS.
14. What are the methods of data storage in Android?
A) file storage
b) xml,sharedpreference
c) sqlitedatabase
D) ContentProvider
e) Network
15. What is the difference between a DVM and a JVM?
A) the DVM executes a. dex file, and the JVM executes a. class. All. Class bytecode compiled by Android will be extracted to a. dex file by the Dex tool.
b) The DVM is a register-based virtual machine and the JVM executes the virtual machine based on the virtual stack. Register access speed is much faster than the stack, DVM can be based on hardware to achieve maximum optimization, more suitable for mobile devices.
c). The. class file has a lot of redundancy information, and the Dex tool removes redundant information and consolidates all the. class files into a. dex file. Reduced I/O operations and improved class lookup speed.
16, talk about the security mechanism of Android
1, Android is based on the Linux kernel, so the Linux control of file permissions is also applicable to Android
Each app in Android has its own/data/data/Package name folder, which can only be accessed by that app, while other apps don't have access.
2, Android rights mechanism to protect the legitimate rights and interests of users if our code wants to make calls, send text messages, access to records, location, access to sdcard and so on all possible violations of the rights and interests of the Act are
Must be declared in the Androidmanifest.xml, which gives the user a right to know.
3, Android code confusion to protect the developer's labor results
17. Do the four components of Android need to be registered in the manifest file?
Activity, Service, contentprovider if you want to use it, you must register it in Androidmanifest.xml, and
Broadcastreceiver has two types of registration, static registration and dynamic registration. Where static registration refers to the androidmanifest.xml in the
Register while registering dynamically with the code.
18. What are the levels of the process in Android?
A) Foreground process
b) Visible Process
c) Service Process
d) Background Process
e) Empty Process
Second, Activity
1. What is Activity?
One of the four components, usually a user interface corresponding to an activity. Activity is the subclass of the context and implements the Window.callback
And Keyevent.callback, you can handle events that interact with the form user.
The common Activity types are fragmentactivitiy,listactivity,tabacitivty and so on. If the interface has a common feature or function, it will define itself as a baseactivity.
2. Please describe the Activity life cycle
Activity from creation to destruction has multiple states, from one state to another, firing the appropriate callback methods, including: OnCreate onStart onresume onPause onStop OnDestroy
In fact, these methods are 22 corresponding, onCreate creation and OnDestroy destruction, OnStart visible and onStop not visible; Onresume editable (i.e. focus) and onPause;
These 6 methods are relative, then only one Onrestart method is left, when is this method called?
The answer is: After the activity has been onStop, but not OnDestroy, when you start the activity again, call Onrestart (and no longer call onCreate) method;
If it is OnDestroy, the OnCreate method is called.
3. What are the status of the Activity?
A) foreground activity
b) Visible Activity
c) Background activity
Empty process
4, how to save the status of Activity?
The status of the activity is usually saved automatically and is only needed if we need to save additional data. In general, activity instances that call the OnPause () and OnStop () methods still exist in memory, and all information and state data for the activity
Will not disappear, and when the activity returns to the foreground, all changes will be preserved.
However, when the system is out of memory, the activity after calling the OnPause () and OnStop () methods may be destroyed by the system, where the activity's instance object is not present in memory. If this activity goes back to the foreground, the changes made will disappear. In order to avoid the occurrence of this kind of situation,
We can override the Onsaveinstancestate () method. The Onsaveinstancestate () method accepts a bundle type parameter, and the developer can store the state data in the bundle object, so that if the activity is destroyed by the system, when the user restarts the activity and calls its Oncrea Te () method, the bundle object above is passed as an argument to the OnCreate () method, and the developer can remove the saved data from the bundle object and then use that data to restore the activity to the state before it was destroyed.
It is important to note that the Onsaveinstancestate () method is not necessarily called, because some scenarios do not need to save state data. Than
If the user presses the back key to exit the activity, the user obviously wants to close the activity, there is no need to save the data for the next recovery, also
Is that the Onsaveinstancestate () method is not called. If the Onsaveinstancestate () method is called, the call occurs before the OnPause () or OnStop () method.
@Override
protected void Onsaveinstancestate (Bundle outstate) {//TODO auto-generated method Stub super.onsaveinstancestate ( Outstate);
}
What are some of the methods that must be executed when jumping between 5 and two Activity?
In general, for example, there are two activity, called A, a, and when the B component is activated in a, a calls the OnPause () method, then B
With OnCreate (), OnStart (), Onresume (). This time B overrides the form, and A calls the OnStop () method. If B is a transparent, or a dialog box style, the OnStop () method of a is not called.
6, the life cycle of the Activity when the screen is switched
The life cycle at this time is related to the configuration in the manifest file.
1, do not set the Activity of the android:configchanges, the screen will recall the various life cycle by default first destroy the current Activity, and then reload.
2, set the Activity android:configchanges= "Orientation|keyboardhidden|screensize", the screen will not recall the various life cycle, will only perform Onconfigurationchanged method.
Usually in the game development, the screen orientation is written dead.
7. How to set an Activity as a window style?
Just configure the following properties for our Activity.
Android:theme= "@android: Style/theme.dialog"
8. How do I opt out of Activity? How do I safely exit a application that has called multiple Activity?
1, usually the user quits an activity simply press the return key, we write code to exit the activity directly call the finish () method on the line.
2. Record Open activity:
Each activity is opened and recorded. When you need to exit, close each Activity.
3. Send specific broadcasts:
When you need to end the app, send a specific broadcast, and after each Activity receives the broadcast, it's off.
To register an activity with the intention of receiving a broadcast
Registerreceiver (receiver, filter)
If you have received a broadcast that closes activity, call the finish () method to drop the current activity finish () by 4 and recursively exit
Use Startactivityforresult when opening new Activity, then flag it yourself, process it in Onactivityresult, and turn it off recursively.
5, in fact, can also be achieved through the intent flag to achieve intent.setflags (intent.flag_activity_clear_top) activation of a new ACTIVITY. At this point, if the activity is already in the task stack, the system will kill all the activity on the activity. Its
The singletop is equivalent to the startup mode configured for the Activity.
9, please describe the Activity of the starting mode and what are the characteristics of each
Startup mode (Launchmode) plays an important role in the process of multiple activity jumps, and it can decide whether to generate new activity instances, reuse existing activity instances, and share a task with other activity instances. Here is a brief introduction to the concept of task, which is
An object with a stack structure, a task can manage multiple Activity, launch an application, and create a corresponding task.
The Activity has the following four kinds of Launchmode:
1.standard
2.singleTop
3.singleTask
4.singleInstance
We can configure the Android:launchmode property in Androidmanifest.xml for one of the above four kinds. Here we combine examples to introduce these four kinds of lanchmode:
8.1 Standard
Standard mode is the default startup mode, which is not required to configure the Android:launchmode property, and you can also specify a value of.
Android Basics to Introductory Learning (review notes)