1. Configchanges: ConfigChanges can be set to three values. If this parameter is not set, the life cycle of horizontal and vertical cuts is twice and that of vertical and vertical cuts is once. Configchanges= “Orientation” Both screen methods go once. Transverse vertical performs a Configchanges onConfigChanged method = “oritation | | keyboardhidden” somehow the screen method is walking again. The onConfigChanged method is executed twice for horizontal cuts and once for horizontal cuts.
Boot mode: 4 options. Standard: The activity instance must be created, specifically onCreate must be executed. SingleTop(SingleTop): in the task stack, the same top does not go onCreate method, suitable for refreshing the page SingleTask(SingleTask): in a task stack, there is only one task, onCreate only go once, if you want to call back to the page, all other page instances on the task stack pop up. SingleInstance: Similar to sharing, the onCreate method only goes once in other task stacks.
Action: Uniquely identifies the Action of an Intent, which can be used to implicitly jump. Category: Further filtering, it represents Category. Extra: We usually use it to store some data. Component Name: indicates the Name of the Component to which the intent belongs. This intent is not commonly used.
A LinearLayout: displays components in horizontal or vertical layouts, using two special properties: weight and layout_gravity. RelativeLayout: Usually requires a reference to indicate the location. It is suitable for center, left, and so on in the parent viewGroup. FrameLayout: FrameLayout: suitable for cascading display of layouts. TableLayout: TableLayout: inherited from the linearlayout, suitable for more standardized data. There is a tablerow that determines the contents of a row. AbsoluteLayout: Indicates the position of the control with pixels. GridLayout: New layout property after 4.0. See calculator.
TableLayout inherit from the LinearLayout. TableLayout can only align controls in one direction. It cannot align controls in both horizontal and vertical directions. TableLayout does not explicitly specify how many rows and columns it contains. Instead, it adds a column to the table by adding other components to it. If you add a component to a table, the component takes up a row. GridLayout cells can span multiple rows. ColumnCount is used to set the number of columns in a GridLayout.
3.Padding and Margin: The distance between the inner content of the control and the boundary of the layout (inside Margin) Margin between the outer control and the control and the boundary of the layout (outside Margin) Gravity refers to the position of the contents of a layout or control relative to the layout or control itself. Layout_gravity Specifies the position used by a control or layout relative to its parent layout
5.ScrollView nested ListView will be a problem? There are two problems: 1. The height of the ListView inside cannot be calculated, usually only one row of the ListView can be displayed. 2. Reset the Height of the ListView according to the Item of the ListView. The layout file of the Item must be a LinearLayout, not another. But then the ListView doesn’t need to scroll because the ListView is already at its maximum height and doesn’t need to scroll. The advantage of a ListView is that it can reuse convertViews, and if you stretch the ListView to its maximum, you don’t reuse it. (no) 2. Custom ListView, rewrite the onMeasure method (not play) 3. The ScrollView have a method, requestDisallowInterceptTouchEvent (Boolean), This method is to set up whether to hand over the onTouch permissions, if let the outer scrollView requestDisallowInterceptTouchEvent (false), the outer layer of the onTouch permissions will lose, So the inside of the listView can get the onTouch permission, and the listView can roll. When the finger touches the ListView, ask the outside ScrollView to surrender its permissions. When the finger is released, the outside ScrollView regains its permissions. It is best to give the ListView and height a fixed value, but not more than the total height.
7. Deal with OOM issues. Here are usually brought about because of eating large memory Bitmap 1 try not to use setImageBitmap setImageResource or BitmapFactory. DecodeResource to set a larger image, because these functions in the completion of decode, Finally is done through Java layer createBitmap, need to consume more memory, can pass BitmapFactory. DecodeStream method, create a bitmap, Set it to source 2 of the ImageView to compress the image using bitmapFactory.options InputStreamis=this.getResources().openRawResource(R.drawable.pic1); BitmapFactory.Optionsoptions=newBitmapFactory.Options(); options.inJustDecodeBounds = false; options.inSampleSize = 10; / / width and hight set as the original is a Bitmap BTP. = BitmapFactory decodeStream (is null, the options). 3. Use Java soft reference to carry out image caching, put the images that need to be loaded frequently into the cache, avoid repeated loading, and timely destroy the Bitmap objects that are no longer used. 4. Picasso was the bitmapUtils xUtils, volley
8. Level 3 Cache: Implementation, respectively is a memory, files, web caching pattern, used mainly in the picture, we first conducted on memory when access to search, mainly through the lrucache key/value pair for bitmap loading, if not we access to the local files on the memory (this application binding cache files) if there is first loaded into memory, Put it into lrucache, and then load it. If the image is not available locally or in memory, we access the network and get the image, save the file first, and then store it in memory for display.
9. The difference between memory leak and memory overflow: Memory overflow out of memory means that the program does not have enough memory space to use when applying for memory. For example: I want to store a long and use an int. I’m running out of memory. Like loading a big bitmap.
Memory leak refers to a program that cannot release the allocated memory space after allocating memory. The damage caused by a memory leak can be ignored, but the accumulation of memory leak can be serious. No matter how much memory is leaked, it will be exhausted sooner or later. For example, if you request an integer but store it for a long, you are out of memory. The Cursor did not close in time. It is usually the large resources that are not shut down.
Listview optimization: 1. Void judgment of convertView, which is to directly reuse convertView when convertView is not empty, thus reducing the creation of many unnecessary views and reducing memory consumption 2. Define a ViewHolder, set the tag in the convetView to the ViewHolder and reuse it if it is not empty so that you do not have to findViewByID each time. 3. When the ListView load data volume is large, you can use pagination load 4. ListView asynchronously load images 11. Blog.csdn.net/oney139/art… Activity. StartManagingCursor method: will get a Cursor object to the Activity management, so the Cursor object lifecycle can with the current Activity automatic synchronization, eliminating the management of the Cursor. 1. This method uses the premise that there are many data records in the cursor result set. Check whether Cursor is null before using it. If Cursor! 2. If you use this method, also use stopManagingCursor () to stop it to avoid errors. 3. The purpose of using this method is to give the acquired Cursor object to the Activity to manage, so that the life cycle of the Cursor can be automatically synchronized with the Activity, saving manual management. There is one case where we can’t close the Cursor directly. This is the case with the CursorAdapter. Note that the CursorAdapter does not automatically close the Cursor when Acivity ends. 12. Android’s performance optimization: blog.csdn.net/hewence1/ar… Bbs.gfan.com/android-800… www.linuxidc.com/Linux/2013-… This paper mainly uses the following 5R method to optimize ANDROID memory:
Use ActivityManager to calculate the amount of memory used by your app, cache, etc. Use Bitmap compression to Reduce the amount of memory used. Modify object reference types (from strong -> soft -> weak -) to reduce the number of objects created and local. When used for the first time, Reuse an image cache, a custom View in an AdapterView, a pool concept, such as a thread pool, etc. Review your program to see if the design or code doesn’t make sense. Code Review, design Review, and view-level Review IPC (Inter-process Communication), the four major components can complete inter-process Communication, but IPC usually refers to the service and page interaction of different processes. AIDL is the abbreviation of Android Interface Definition Language, which is a description language of Android internal process communication Interface, through which we can define the communication Interface between processes. The compiler can use a file with the extension AIDL to generate a piece of code that communicates between two processes through a predefined interface.
SendMessage () : When sending a message, label the message sent by the Handler with message.target=this. 3. Start the polller in the run method of the HandlerThread class: EnqueueMessage (Message MSG, long WHEN) in MessageQueue That is, the message is queued according to the incoming time. In looper.loop (), the MessageQueue object is retrieved and the Message (Message MSG = queue.next()) is retrieved from it. If there is no Message, the Message will be blocked. From the message queue, call MSG. Target. DispatchMessage (MSG); 9. Send the processed messages to the specified handler. That is, call the dispatchMessage(MSG) method of the Handler to send messages. Recycle the message: After the message is used, call msg.recycle() in the looper.loop () method to recycle the message, that is, restore all the fields of the message to the original state.
15. Use of SQLite database: We use SQLiteDataBase objects in our databases. We can use sqliteOpenHelper to get a database object that is readable and writable. We can also use SQLiteDataBase objects to open an existing database using context. Add, delete, change and check the database, at the same time, this way can have three kinds: string splicing, placeholder, system.
16. How to start a service and its lifecycle? How to stop a service? The first method is to start the Service with startService(Intent) and invoke onCreate and onStartcommand in the Service lifecycle. OnCreate is invoked only once when the Service is created, and onStartcommand can be invoked multiple times. Terminate the service with the stopService() method and call the lifecycle onDestroy method. The second way is to start with bindService(), calling the onCreate and onBind methods of the lifecycle, both of which are executed only once; End the service with unbindService (), calling the lifecycle onDestroy method.
An intent object is used to determine who is going to broadcast a broadcast to, and the receiver calls onReceive. A: From an MVC point of view (within an application), the answer to this question could be: Why does Android have those four components? The current mobile development model is basically the same MVC architecture as the Web, but with a change of dowry. The four components of Android are essentially to realize MVC architecture on mobile or embedded devices. Sometimes they are interdependent, sometimes they are complementary. The introduction of broadcast mechanism can facilitate the information and data interaction of these components. C) efficiency (refer to the convenience of UDP broadcast protocol on LAN) D) design mode (an application of reverse control, similar to listener mode)
17.Android has four components: Activity, Service, Broadcast Receiver, Content Provider. Activity: In an application, an Activity is usually a single screen that displays controls and listens to and responds to user events. Activities communicate with each other through intEnts. Service: A Service is a long-life, non-user interface program that can be used to develop programs such as monitor programs. BroadcastReceive: Your application uses BroadcastReceive to filter external events and only receive and respond to external events of interest, such as when a phone call comes in, or when a data network is available. The broadcast receiver has no user interface. However, they can start an activity or serice in response to the information they receive. Content Provider The Content Provider is used to share data between multiple applications. This data can be stored on a file system or in an SQLite database.
18. How does ContentProvider implement data sharing and what are its advantages? Create a class that inherits ContentProvider and add the Provider label to the androidmanifest.xml file, indicating the authority information. This information can uniquely identify the provider and be used by the outside world to find the provider. The result is a URI — content: // Authority information + data path. Get a contentResolver object in an application that needs to access data. This object adds, subtracts, modifies, and queries data using a URI. Advantages: A program can be exposed through the ContentProvider’s own data. The outside world does not see or need to see how the data exposed by the application is stored in the application, or stored in a database, or in a file. The outside world can add, delete, change and check the data through a unified interface — URI
19. How to ensure that the background service is not killed? 1. Rewrite the onStartCommand method of the service and change the return value to START_STICKY.START_STICKY: If the service is killed, retain the start state of the service but do not retain the intent object delivered. The system then attempts to recreate the service. Since the service is in the start state, the onStartCommand method must be called after the service is created. If no start command is passed to the service, the intent parameter is null. 2. Restart the service in onDestroy, but sometimes the onDestroy method is not executed when forced to stop, so the service will not restart. 3. Improve the Service process priority and use startForeground to bring the Service to foreground. StartForeground (int, notification) 4. Listen to system broadcasts to determine the service status, for example, start the service when the mobile phone restarts. 5. The same application starts two processes and listens to each other. If one process is killed, the other process starts to survive to the maximum extent.
20. Steps for custom controls: There are three ways to implement Android custom components: Inherit an existing component, add additional functions on its basis, such as inherit Gallery to achieve CoverFlow effect inherit a Layout, realize composite component customization, such as TextView and EditText combination to achieve login registration component inherit View, realize onDraw() method, Implement your own drawing components, such as page-turning effects components
21. HTTP request mode: difference between TCP and UDB (three-way handshake) Request mode: GET and POST. The differences between the two are as follows: GET carries less information, has low security performance, is fast, and can be displayed on the URL. Post carries a lot of information, but has high security and slow speed. It is not displayed on the URL. TCP protocol is the first to complete the three-way handshake, establish a complete channel, similar to a phone call, the message must be transmitted, mainly using streams or binary arrays to transmit information. UDP does not require a three-way handshake. The UDP protocol is fast, and messages cannot be received. It is similar to broadcast. It mainly uses data packaging and unpacking.
22. The fragment life cycle and communication between fragments and between fragments and activities the fragment life cycle is attached to activities
Fragment and activity communication: You can actually use broadcast and file communication, but consume resources, so you use the lifecycle method, which is: The activity defines a member variable, and an interface is defined in the Fragment. The first method in the Fragment lifecycle, onAttach, passes an activity parameter that allows us to access the activity’s member variable. When an activity wants to retrieve parameters in the Fragment, it can retrieve parameters in the fragment through callback as long as the interface of the fragment is implemented.
23. Process Priority 1. Foreground process: process 2 where the page that is interacting with the user resides. Visible process: When an activity page is rendered using a dialog, the process in which the page below the dialog is located is visible process 3. Service process: app with push function, wechat 4. Background process: Click the home button, and the background process is the background process. Pulltorefresh this is a pull-up refresh, pull-down load adapterView, can complete the pull-up refresh, pull-down load. We usually use it on the ListView, and it’s actually done using methods in the OnScroll interface. We can get a visible item, the item seen on the screen and the total item, and determine whether it is the end or the end. At this point, we can add headers and tails to control the refresh and load. Listview.setmode (mode.both); listview.setMode (mode.both); / / when the refresh support sliding listView. SetScrollingWhileRefreshingEnabled (true); / / set the drop-down and listening, through refreshView gets the current position, for its own operation listView. SetOnRefreshListener (new OnRefreshListener () {
@Override public void onRefresh(PullToRefreshBase<ListView> refreshView) { int y = refreshView.getScrollY(); setDatas( y<0 ); }});Copy the code
Face++ can be used in face recognition by passing a simple binary stream file, access the server, according to the json string to obtain the age and gender, the main method is detectiondetect, but according to the requirements of the need to use binary file stream, And the size is different, so we need to first carry out the image information compression, in the conversion of binary stream, as a parameter. When comparing similarity, the main method is recognitionidentify, and a library with faces needs to be given. The generation of this library is due to the information of people, groups and faces, so we need to create a new group, a new person and a new face, and train after joining. The method is as follows: Group /create group/add_person adds groups and people, but requires training, so use train/identify and train/verify to train groups and people
Xutils: Onist DbUtils module: Android ORM framework, which allows a line of code to be added, deleted, changed and checked. supports a transaction, which is closed by default; customizes the table name, column name, foreign key, uniqueness, NOT NULL, CHECK, etc. (propose the table name and column name when obfuscation is required). supports binding foreign key, which automatically saves or updates the foreign key associated entity when the entity is saved. automatically loads the foreign key associated entity, supporting delay loading; supports chain representation of a query, which provides a more intuitive query semantics, refer to the following introduction or the example in sample.
Android: Propose ViewUtils module: IOC framework in Android, which fully annotates UI, resource and event binding; a new event binding method that works properly after obfuscation using the obfuscation tool; currently used 20 kinds of support event, see ViewCommonEventListener classes and packages. Com lidroid. Xutils. The annotation. The event.
supports synchronous and asynchronous request. supports large file upload, upload large file does not oom; supports GET, POST, PUT, MOVE, COPY, DELETE, HEAD, OPTIONS, TRACE, CONNECT request; download supports 301/302 redirection and supports setting whether to rename a downloaded file according to Content-Disposition; Returns a request with text content (only a GET request is enabled by default) that supports caching and allows setting a default expiration time and expiration time for the current request.
mapUtils module: loads bitmap without considering oom during bitmap loading and image dislocation when The Android container is sliding rapidly. Supports loading network image and local image; Memory Management uses the LRU algorithm to better manage bitmap memory. configurable thread load thread number, cache size, cache path, load display animation, etc…
27. The volley framework blog.csdn.net/xyz_lmn/art… JsonRequest and ImageRequest are included for httpClient and asynchronous load image encapsulation, and end up if the Activity exits unexpectedly at this point.
Picasso is a three-party JAR package for loading images asynchronously. The principle is that when we slide the ListView, there will be a dislocation. By tagging the image, we will compare the URL of the tag and the image when loading the last time, so as to solve the dislocation. Use a level 3 cache to store images (see article 8). We need to configure SDK, 1) get ShareSDK AppKey 2) download SDK 3) Step 1: make quick tool integration
Step 2: Configure androidmanifest.xml
After completing the above operations, you can perform shareSDK operations such as three-party login and sharing.
30. The use of MVC in Android (M/V/C, and the use of Web) Android interface also adopts the currently popular MVC framework, in Android: 1) View layer: XML file is generally used to describe the interface, which can be very convenient to introduce when using. Also can use JavaScript+HTML and other ways as a View layer, through the WebView component loading, and can realize the communication between Java and JavaScript. 2) Controller: Another reason for this is that the response time of the Acitivity in Android is 5s. If the time-consuming operations are placed here, Android’s control layer usually falls on the shoulders of a lot of Vity, and applications can be easily recycled. 3) Model layer: Operations on database and network should be handled in Model. Of course, operations on business computing must also be placed in this layer. Data binding in the Android SDK also adopts a similar approach to MVC framework to display data. Data binding is achieved by wrapping the data in the control layer according to the requirements of the viewmodel (that is, the Adapter in the Android SDK) and displaying it directly on the viewmodel.
For example, the view layer of a ListActivity that displays all data in a Cursor is a ListView. The data is encapsulated as a ListAdapter and passed to the ListView. The data is displayed in the ListView. In Web, mode is Java code, View is A JSP or HTTP page, and Controller is a web.xml configuration file
31. Data storage in Android: 1. Use SharedPreferences to store data; 2. File storage data; 3. SQLite database stores data; 4. Use ContentProvider to store data; 5. Network storage data;
ANR: Application Is Not Responding, five seconds In Android, two system services, the activity manager and window manager, are responsible for monitoring the Application’s response. Android displays the ANR dialog when: The response to input events (such as keystrokes, touch screen events) exceeds 5 seconds and the intentReceiver continues to execute for more than 10 seconds. The Android application runs entirely on a separate thread (such as main). This means that any operation that takes a lot of time to run on the main thread will raise an ANR. Your application has no chance to respond to incoming events and Intent broadcasts. There are two solutions: In asynchronous tasks, doInBackground() and onPostExecute(Result) are two important methods. DoInBackground () is a method that runs in a background thread and performs time-consuming operations. Such as mobile care system network connection, parsing XML operations. This method must be overloaded. OnPostExecute (Result) this method also runs on the UI thread, in doInBackground(Params…). Called after the execution of the method, which is used to process the result returned after the execution of the background task. 2. The child thread + handler handler’s operation mechanism (works) (MessageQueue handler, which, the relationship between the Message) a handler allows you to send and process Message and Runable object, Each thread has its own Looper, and each Looper encapsulates a MessageQueue. Looper is responsible for the task or message execution that continually removes the queue head from its own message queue. Each handler is also associated with a thread. The handler is responsible for passing Message and Runable objects to MessageQueue (using post, sendMessage, etc.), and when these objects leave MessageQueue, Handler is responsible for executing them (using the handleMessage method). The Message class defines a Message containing a descriptor and any data Object that is passed to the handler. Message Object to provide two additional int fields and an Object field.
33. Find Java/Android runtime exceptions,error,exception(at least 10), and find Arithmetic exception(at least 10). IllegalStatement Exception: invalid argument Exception: invalid argument Exception: invalid argument Exception ClassNotFoundException: No exception was found when we loaded the class, but the definition of the class with the specified name was not found. InterruptedException: Interrupts an exception thrown when a thread is in the waiting, sleeping, or occupied state before or during an activity and the thread is interrupted. IOException:I/O exception This type of exception is generated by a failed or interrupted I/O operation
NoSuchMethodException: Thrown if a particular method cannot be found without a method exception
ParseException Parses an exception, indicating that an unexpected error occurs during parsing
ClassCastException: Type casting exception that occurs when a type is cast that is not a subclass object.
IndexOutOfBoundsException: unusual subscript bounds, appeared in the arrays, and strings.
FileNotFoundException: Unable to find file exception, when we point to a file, the file may not exist
NullPointerException: A NullPointerException occurs when we try to call an empty object
SecurityException: a SecurityException that occurs in the database and may require permissions.
Have you declared your activity in your androidMainfest.xml? Activity is not configured in the manifest file Have you override your method in your method? ViewPager we didn’t override method Can’t find the Resources in your R file: when setText is set to int, we’re actually looking for the contents of R file. In Android, android system architecture: Application layer Java language Application development Application framework layer Java language OS custom framework layer Development system runtime layer C++ implementation so library Linux kernel layer The Android system architecture is Linux from bottom to top The advantages and disadvantages of Android platform: 5 advantages of Android platform mobile phone: first, openness in terms of advantages, Android platform is the first of its development, the development of the platform allows any mobile terminal manufacturers to join the Android alliance. Significant openness can make its have more developers, as the user and application of the increasingly rich, a new platform will mature quickly Development for the development of Android, conducive to the accumulation of popularity, the sentiment, including consumers and manufacturers, and for consumers, with big benefit is rich software resources. Open platforms will also bring more competition, so consumers can get their handsets at lower prices. For a long time in the past, especially in Europe and the United States, mobile phone applications were often restricted by operators, which almost controlled what functions they could use and what networks they could access. Since the iPhone went on sale last year, users have been able to connect to the Internet more easily and carriers have fewer constraints. With the gradual transition and improvement of EDGE, HSDPA, 2G to 3G mobile networks, mobile phone access to the network is no longer a joke in the mouth of operators, when you can easily carry out instant chat through mobile PHONE IM software, then recall the price of MMS and map bell download business not long ago, is it like a nightmare? Google’s Android devices are inherently Web oriented and will bring users closer to the Internet. This point is still related to the openness of the Android platform, because of the openness of Android, many manufacturers will launch a variety of strange, functional features of various products. Differences and features in functions will not affect data synchronization or even software compatibility. For example, if you switch from Nokia Symbian style mobile phone to Apple iPhone, you can also bring excellent Symbian software to iPhone for use, and transfer information such as contacts easily. Is it very convenient? The Android platform provides a very broad and free environment for third-party developers, which will not be hindered by all kinds of rules and regulations. It is conceivable that there will be many novel and unique software. But there are two sides to it, and blood, violence, and sexual aspects of apps and games that are controllable are just one of the challenges left for Android. Google has gone through 10 years of history from the search giant to the comprehensive Penetration of the Internet, Google services such as maps, mail, search has become an important link to connect users and the Internet, Android phones will seamlessly combine these great Google services. Security and privacy Due to the close connection between mobile phones and the Internet, it is difficult to protect personal privacy. In addition to the process of surfing the Internet intentionally or inadvertently left a personal footprint, Google this giant is always standing behind you, penetrating everything, therefore, the Internet will bring a new round of privacy crisis. T-mobile announced its first Android phone, the G1, in New York on Wednesday. But in North America, where AT&T and Verizon are the two largest carriers, only T-Mobile and Sprint are known to sell Android phones. T-mobile’s 3G network is inferior to the other three, so customers can buy the G1. Whether you can experience the best 3G network service is another matter! Third, operators can still influence Android phones in the domestic market, many users are dissatisfied with the purchase of customized mobile phones, feeling that the purchased mobile phones are painted by people like advertising. This situation also appears in foreign markets. Sprint, another carrier offering Android phones, will build its mobile store app into its phones. In many mobile phone forums, there will be sub-forums for a certain type of mobile phone to exchange experience on the use of a mobile phone and share software resources. For Android phones, due to the variety of manufacturers and product types, fewer and fewer users use the same model, and the program enhancement of the unified model is lacking. To take a slightly inappropriate example, there is little discussion or group devoted to any particular model of shanzhai, except for the ones that are popular and have eye-catching features. When you use Windows Xp on PC, Microsoft’s Windows Media Player comes with a built-in browser that allows you to choose from a wide variety of players, such as Realplay or Storm. But starting with a default program can also meet a variety of needs. In Android platform, due to its openness, the software relies more on third-party manufacturers. For example, there is no built-in music player in the SDK of Android system, and all rely on third-party development, lacking the unity of products. 36. Differences between assets and RES/RAW: The similarities between RES/RAW and Assets are as follows: Files in the two directories are stored intact in the APK package and will not be compiled into binary. The differences between RES/RAW and assets are as follows: 1) Files in RES /raw are mapped to r.Java files. When accessing files, the resource ID is r.raw.filename. Files in assets will not be mapped to R.Java and will be accessed using the AssetManager class. Res /raw cannot have a directory structure, while assets can have a directory structure. You can create folders under assets. InputStream is = getResources(). OpenRawResource (r.raw.filename); InputStream is = getResources(). Read the file resources under assets and perform write operations by obtaining the input stream AssetManager am = NULL. am = getAssets(); InputStream is = am. Open (” filename “); 37. Touch Distribution events:
When we click on the innermost View or ViewGroup, we are actually passing it down from the bottom DecorView, but we need to intercept two times, dispatchTouchEvent and InterceptTouchEvent, which return false by default. When we return True, we intercept it, and when we pass it straight to the lowest level without blocking it we pass up onTouchEvetnt, which also returns false by default, and when we return True, we consume the event, It means that we have processed the Touch event, and there is no need to process it later. If all returns are false, then the Touch event will be ignored
38. Bitmap compression (bitmap access) for bitmap method: 1. BitmapFactory. DecodeXXX: bitmap to obtain this way to get from some other resources. These other resources include binary byte arrays (byte[]), files (file), project resources (RES), streams, and file descriptors (FileDescriptor). When obtaining Bitmap from other external resources, the image resources may be too large, which is easy to occur OOM. For details, please refer to title 2 below. Bitmap.createbitmap (XXX, XXX, XXX…) A Bitmap created in this way is usually created from an existing Bitmap. (Use the prototype pattern in design Mode)
If you need to use the same layout design in a project, you can reuse layout code using tags to reduce view hierarchy: You can further optimize the layout code by removing the FrameLayout declaration from the Layout file. But because the layout code needs to be contained in the outer container, if you simply delete FrameLayout, the file is not a valid layout file. In this case, you can use the tag. 1) Install and download Cygwin, download Android NDK 2) Design of JNI interface in NDK project 3) use C/C++ implementation of local methods 4)JNI generate dynamic link library. 41. Java garbage collection mechanism,
In Java, we use Garbage Collection(GC) to manage objects. Although we omit the Garbage Collection step, it is not easy to influence objects. We can only use System.gc () to notify garbage manager to recycle. When garbage manager finds that an Object is empty or does not point to a reference, garbage manager will recycle it from time to time. Every Object inherits from Object, so GC completes finalize() method to recycle. If we implement the Closeable interface, we will need to manually close it because the GC will no longer close this part of the resource.
42. Screen fit: It is best to assign the size of each component by layout_weight, or by specific pixels (DIP). Use Relativelayout whenever possible. Given the platform device resolution supported by the application, multiple layout_320*480 can be provided… Drawable -hdpi,drawable-mdpi,drawable-ldpi = 480*800,360*480,240*360 Without this paragraph, adaptation cannot be achieved: \