Android driving recorder control board development
With the continuous development of our country's social economy, the transportation industry has developed rapidly, the number of motor vehicles has increased sharply, and the number of private cars has also continued to grow. The scale and level of traffic management have gradually expanded, and the resulting problems have also continued to increase. . For this reason, the implementation of intelligent traffic management, improvement of driving safety performance, and improvement of traffic chaos have attracted more and more attention from the industry. As a smart car driving recorder APP that guarantees the safety of cars, it came into being, because many emergencies may be encountered during driving, and keeping appropriate on-site data becomes an indispensable link to deal with emergencies. Research on it , development and application also attracted some IT practitioners.
The research of this thesis is based on the Android platform. Under this platform, the design and implementation of the intelligent driving recorder APP is carried out, that is, the intelligent driving record function is realized by using the Android mobile phone without designing the hardware separately. At present, the replacement speed of mobile phones is getting faster and faster. Many people have two or more mobile phones. The obsolete old mobile phones are used as the hardware platform of the smart driving recorder APP, saving hardware costs. At present, people are relatively proficient in the operation of mobile phones, and the development of smart driving recorder APP also facilitates people's use to some extent.
Based on the above conclusions, this paper designs a smart driving recorder APP based on the Android platform, which will be elaborated below.
1. Functional design of driving recorder system
The bottom layer of the Android system is based on the Linux 2.6 version of the kernel, such as process management, file system, etc. The kernel is a bridge between the upper layer software and the underlying hardware. The Android system framework can be roughly divided into four parts: application layer, application framework layer, library and Android runtime, and Linux kernel.
This system is developed on the Android application layer. According to the requirements, the mobile application mainly has the following functions. One is to provide route planning according to different travel modes, the other is to provide real-time navigation according to the The direction sensor gives the direction and latitude and longitude, the fourth is the function of taking photos and videos, the fifth is the display of activities, the sixth is the realization of the music playback interface and functions, the seventh is the viewing of news and surrounding pages, and the eighth is the file management function, including pictures and Video thumbnail, list display function, picture viewing and video playback function, one-click cleaning and sharing function of picture and video files, and connect to computer, use computer to manage mobile phone files.
2. Functional realization of driving recorder system
The client side of the system uses the two major components of Activity and Service, making full use of the Intent communication mechanism, supplemented by SharedPreferences to store data, HTTP protocol and server communication, and using the services provided by the Mob mobile developer service platform and Baidu map development platform. Successfully built a feature-rich smart driving recorder APP.
The system server uses Servlet to receive the request sent by the client. Since it only needs to return the data to the client and does not need to display the graphical interface through the browser, there is no need to write jsp. The system uses a MySQL database, and uses a jdbc bridge connection between the server and the database.
2.1 Navigation
(1) Baidu Maps SDK: Baidu Maps Android SDK is a set of application program interfaces based on Android 2.1 and above devices. By calling the SDK interface, you can access the services and data of Baidu Maps. All the services it provides are free. The number of times the interface can be used is unlimited. When using, you must first apply for a key (key), and set the Accesskey in Mainfest.xml, and add <meta-data android:name="com.baidu.lbsapi.API_KEY"android:value="key" in the application tag />, and declare the corresponding permissions, and at the same time import the corresponding resource Jar package, .so dynamic library. Baidu Maps provides ordinary 2D and 3D maps and satellite images, and supports POI retrieval, geocoding and reverse coding, route planning, map overlays, location positioning and other special services. The technology used in this system is briefly introduced below.
Baidu map Android positioning SDK is a set of easy-to-use LBS (Location Based Service, location-based service) positioning service interface provided for Android mobile applications, which can provide GPS, base station, WiFi and other positioning methods. To use, you need to add MapView in the xml file first, and then enable the positioning layer. In the positioning initialization process, first instantiate the LocationClient, then register the positioning monitor, and finally set the positioning parameters, such as the selection of the coordinate system, the control of the positioning time interval, etc. The location monitoring function will return the location information, which can be displayed on the interface by setting the location information. When exiting the location interface, the location layer should be closed and the LocationClient should be destroyed to prevent memory leaks. The principle of Baidu Map Android Navigation SDK is similar to that, so I won’t go into details here.
(2) Function realization: First of all, when people use the navigation function, they need to find the route from the current location to a certain place. Therefore, the system first obtains the current location using the Baidu Map Positioning SDK, and draws it on the page Show signs such as streets and hotspots to provide users with navigation basis. Then, the starting point and ending point input boxes on the page can input the location, and the associative word function (Sug⁃gestionSearch) will be triggered when inputting, intelligently prompting the user for the corresponding location.
2.2 File Management
The files that need to be managed by this system are video and picture files. The video files are generated by calling the system camera recording, and the picture files are generated by calling the system camera. The generated files are all stored in a custom file. Instrument files are distinguished from other files in the phone for easy management. In order to improve the user experience, the file management interface provides list and thumbnail display functions. Clicking on the files and thumbnails in the list can play them. At the same time, often pressing the thumbnails will pop up a custom dialog box. The function of the custom dialog box is sharing , delete files, etc.
(1) Thumbnail implementation: Both picture and video thumbnails use the GridView layout. Adding an Adapter to the Grid⁃View can dynamically add the number of thumbnails according to the number of files. Here, the self-defined Adapter inherits BaseAdapter in the way of callback. There are four methods to be implemented, the most important of which are two, getCount() and getView(). getCount() returns the number of thumbnails, and getView() To return the thumbnail, an ImageView object needs to be created in the process of returning the thumbnail, and the combination of ViewHolder and convertView can not repeatedly create the ImageView object. convertView.setTag() is to save the created ImageView object in the convert ⁃View, to be reused, convertView.getTag() is to take out the ImageView saved in convert⁃View for reuse. The above is to display the generated thumbnail on the interface, and the thumbnail file of the generated image uses the bitmap factory BitmapFactory, through which a copy of the original image can be generated, and its format is bitmap, and the size can be modified. The resulting image is the desired thumbnail file. To generate a video thumbnail file, first use ThumbnailUtils to create a video thumbnail, and then use ThumbnailUtils to generate a thumbnail of a specified size. Generating thumbnails is a time-consuming operation. At this time, asynchronous loading can be used to process the part of generating thumbnails in the sub-thread, and the main thread is responsible for displaying on the interface. This system uses a custom asynchronous class to inherit AsyncTask, and rewrites the two methods of doInBack⁃ground and onPostExecute to achieve the desired function.
(2) View picture function: In order to be able to display in full screen, first obtain the screen resolution through DisplayMetrics, and then pass the obtained picture through BitmapFactory to generate a full-screen picture.
(3) Video playback function: first, hide the status bar through WindowManager when playing, and to play video, you first need to decode. The native Android video playback framework supports a small format. At this time, you can use some open source frameworks, such as Baidu's Android Player SDK or vitamio, an all-round multimedia development framework, supports hardware decoding and GPU rendering. This system uses Baidu's Android player SDK, which provides support for media playback display through BVid⁃eoView, and BMediaController provides support for media playback control. When using these, you need to import Jar packages, .so dynamic libraries and corresponding resource files .
2.3 Music Player
In order to realize the music playback function, first customize the service, and realize the background music service by inheriting Service, one of the four major components of Android. Service can be understood as an Activity without an interface, but Service has a higher priority than Activity. In the definition service, the UI interface such as refreshing the progress bar, duration, and current music name is realized through the Handler mechanism. At the same time, methods such as playing the current music, playing the next song, and pausing playback are provided. To implement these methods, you need to call the Android MediaPlayer class. Obtaining music information requires another component, ContentResolver. ContentProvider and ContentResolver are a pair. ContentProvider is used to provide content for other applications to operate, and ContentResolver is used to operate its own or other application data. The Media information is queried through the ContentResolver, and then the information is encapsulated into a Parcelable class and provided to the Service for processing. The display of the music list is realized through ListView. When invoking the Service service in the Activity, first obtain the IBinder object returned by the custom service through onBind through ServiceConnect⁃tion. Through the IB⁃inder object, you can call all public access methods in the Service, and you can also register BroadcastReceiver to receive the service sent. The broadcast performs the appropriate action. Android's IPC communication uses a more suitable IBinder mechanism, rather than Linux's semaphore, shared memory, message queue and other communication methods.
2.4 Weather conditions
For services that need to obtain real-time data such as weather conditions, it is necessary to find a data service provider that provides stable and accurate data. This system chooses Baidu Weather API. First, return to the city where the mobile phone user is located through Baidu map positioning, and then create a sub-thread to obtain weather data using the Http protocol. The weather data returned by Baidu Weather is in xml format. Real-time weather data can be obtained by parsing xml, and then use Handler Refresh the main thread and display the weather conditions on the main interface.
2.5 Personal center
The personal center is designed with the C/S structure method combining WebService and Android. To realize the personal center page, registration and login functions must be realized. First, a database must be built to store information such as user names and passwords. This system uses a MySQL database. The structure is shown in Table 1 below. First, create a new Web Project in MyEclipse, which connects to the database through the JDBC bridge, which is a unified API provided by java to access the database. Then create two new Servlets, one provides a response for client login, and the other provides a response for client registration, both of which are deployed under Tomcat. The client sends a request, and the server completes the operation of registration or login verification. ⁃sponse to carry data, and finally realize the client login and registration functions.
Summarize
Aiming at the current situation of driving safety, an Android-based driving recorder APP is designed and implemented. This design not only helps to improve traffic chaos, but also saves hardware costs. In terms of functional design, the system can not only locate and navigate the route, but also can take pictures and videos, manage pictures and video files, and provide music playback and other functions to fully meet the needs of users during driving. With the continuous improvement of user space, users will experience more satisfactory services.
The above is an example of the design and development of an Android-based smart driving recorder introduced by Shenzhen Zuchuang Microelectronics Co., Ltd. If you have a driving recorder solution development demand, you can rest assured to entrust it to us. We represent a variety of single-chip microcomputers, voice chips, dual-mode Bluetooth ICs, and wifi chips. Brands include Songhan MCU, Yingguang MCU, Jerry Bluetooth, Ankai Bluetooth, Allwinner, and Realtek. Our technical services include: PCB design, microcontroller development, Bluetooth solutions, software and hardware custom development, APP development, small program development, WeChat official account development, etc. It can also undertake the design of intelligent electronic products, the development of living appliances, the research and development of beauty equipment, the application of Internet of things platform, the smart home control system, the development of TWS earphones, Bluetooth earphone speakers, the development of children's educational toys, the design of electronic education products, etc.
Proposal recommendation
- TOP