[JAVA] [Android] Develop a service that allows university students to check the operating status of buses circulating in the university.

Background

A team of four will develop a service that allows you to check the current location of buses and the congestion status on the Web by analyzing the location information of buses circulating on campus and images inside the campus in a university independent study. became. The development of the whole team has settled down, and I posted it with the intention of summarizing the areas I was in charge of.

It may be difficult to understand because it focuses on the content that I was in charge of. I would be very grateful if you could report any points that are difficult to understand ** or points that should be corrected **.

Please refer to the material posted on slideshare for the contents of other personnel. Try developing a university circulation bus system as a team. The source code is on GitHub.

1. Introduction

1.1 What is a bus client?

With this system I was in charge of developing the bus client. The role of the bus client is to measure the location information and congestion status of the bus. Sending the image on the bus to the API server. This is the role of the bus client in the entire system. システム全体の中でのバスクライアントの役割

1.2 specifications

A bus client is realized by developing an Android application with the following three functions and installing an Android terminal on which the application is installed in the bus.

  1. Send the location information data acquired from Wi-Fi and GPS to the API server every 10 seconds.
  2. Encode the image in the bus to Base64 and send it to the API server every 10 seconds.
  3. Send the transmission data of 1. and 2. in JSON format.

The contents of JSON data (left: location information, right: image information). JSONデータの中身(左:位置情報、右:画像情報)

1.3 Environment used

--Integrated development environment: Android Studio --Language used: Java --Android device used: VAIO Phone A VPA0511S

1.4 File description

tamabus   ├ AndroidManifest.xml   ├ MainActivity.java   ├ UploadTask.java   ├ activity_main.xml   ├ colors.xml   ├ strings.xml   └ styles.xml

--AndroidManifest.xml: A file that describes the permissions to use --MainActivity.java: The program described here works. --UploadTask.java: Asynchronous communication processing class when posting data to the server --activity_main.xml: File that describes the layout of the application screen --colors.xml, strings.xml, styles.xml: Files that contain information such as colors, character strings, and formats used in the app.

2. Main paper

2.1 App screen, function flow

The following is the screen of the app. The camera is always activated and it continues to be projected on the TextureView object, which is an Android GUI component. Below the TextureView object, blue letters represent latitude and red letters represent longitude. Below the latitude and longitude, the elapsed time since the app was launched is shown. The elapsed time is updated every 10 seconds, and when the elapsed time is updated, it can be seen that the position information and the image information have been transmitted.

アプリ画面

The flow after launching the app is as follows. After initializing the variables, etc., check whether the location information authority and camera use authority are permitted. If both permissions are allowed, the flow from "Get location information from GPS" to "Post encoded image" is looped every 10 seconds.

アプリ起動からのフロー

2.2 Issues that have occurred

2.2.1 The camera cannot shoot fully automatically.

At the beginning of development, I thought that automatic shooting with a camera could use the Intent class function of Android Studio to call a genuine camera app and shoot automatically with the launched camera app. However, it turns out that the genuine camera app can't take pictures unless someone presses the shutter, and it can't take pictures automatically. How to get the image in the bus was the biggest issue at the beginning of development.

2.2.2 The posted encoded image data cannot be decoded on the receiving side.

The image taken on the bus client side is encoded with Base64, and the image data converted into a character string is sent to localhost in the test. The receiving side succeeded in receiving the character string of the image data, but could not decode the character string.

2.3 Solutions to problems that arise

2.3.1 Do not start the genuine camera app.

I was looking for information on how to get an image other than launching the genuine camera app and pressing the shutter to shoot, but I couldn't find it. So I thought that I could find it if I searched for information in English, and when I searched for information in English, I captured what was in the camera into the TextureView object of the GUI component, and captured the image that was transferred to the TextureView object in a certain period of time. I found a method called, and I was able to solve the problem with this method.

2.3.2 Posting will force the + sign to be replaced with a half-width space.

If I decoded it on the Android side before sending the encoded character string, it could be decoded correctly, so I guessed that Post might be the cause. After investigating, I found that the + symbol in the posted character string was replaced with a half-width space. I sent the data to localhost in the test. The red line below is the part converted to a half-width space. 赤線部が半角スペースに変換された箇所

The problem was solved by creating a program that replaces the half-width space included in the character string received on the server side with the + symbol.

3. Conclusion

3.1 I tried sending to localhost

We built an environment on localhost to display JSON data of location information and image information received by XAMPP. You can see that the data can be sent correctly. localhost側で受信したデータの中身

3.2 Future plans

The bus client that I am in charge of has been completed, so I plan to help with image analysis that analyzes the degree of congestion from the transmitted images. I would like to adjust the schedule with the members, resume development, and bring it to operation.

Recommended Posts

[Android] Develop a service that allows university students to check the operating status of buses circulating in the university.
Android development, how to check null in the value of JSON object
Creating an ArrayList that allows you to throw in and retrieve the coordinates of a two-dimensional plane
How to use UsageStatsManager in Android Studio (How to check the startup time of other apps)
A memo of the program that allows you to realize that the probability of dice rolling is about 1/6
Create a database of all the books that have been circulating in Japan in the last century
I tried to develop the cache function of Application Container Cloud Service in the local environment
Check the dependency of a specific maven artifact in Coursier
Determine that the value is a multiple of 〇 in Ruby
Command to check the number and status of Java threads
A program that counts the number of words in a List
How to check for the contents of a java fixed-length string
Three Reasons to Frustrate Before the Release of a Web Service
Check the migration status of rails
A memo that was soberly addicted to the request of multipart / form-data
The story of forgetting to close a file in Java and failing
Sample program that returns the hash value of a file in Java
We have released a service that allows you to easily create chats!
How to change the value of a variable at a breakpoint in intelliJ
How to get the absolute path of a directory running in Java
A simple application (CT) that allows you to view the RDSR in which the radiation exposure dose is recorded.