Example of data detection effect of pressure cooker using JNI for Android

This paper describes the effect of Android using JNI to realize pressure cooker data detection. Share with you for your reference, as follows:

1. Create home page:

2. Write monitor. C in the JNI folder

3. Layout file:

4. Progress bar code

5. Go to the SRC directory of the project, open the CMD window, and enter:

Generate file com_ android_ imooc_ jni_ Open monitoractivity and copy the two methods to monitor. C

6. Implement the above two methods

1) First, get the progress bar on the main page

2) Implement the startmonitor method in monitor. C

3) Because the above method uses a while (1) loop, sub threads must be used in the methods of Java pages

4) How to stop?

Define the variable int monitor; In method Java_ com_ android_ imooc_ jni_ MonitorActivity_ Initialize to monitor = 1 in startmonitor

In method Java_ com_ android_ imooc_ jni_ MonitorActivity_ The stopmonitor is initialized to monitor = 0

7. The final code is monitor. C

Home page code:

8. The effect is shown in the figure

More readers interested in Android related content can view the topics on this site: summary of Android basic component usage, introduction and advanced tutorial of Android development, summary of Android layout skills, summary of Android view skills, summary of activity operation skills of Android programming, summary of Android resource operation skills, and Android control usage summary

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>