Service usage examples developed by Android

This article illustrates the service usage of Android development. Share with you for your reference. The specific analysis is as follows:

Service is a program with a long life cycle and no interface.

Let's learn from an example of playing MP3.

First look at mainactivity.java

Two buttons are defined on the interface.

Look at musicservice.java again

Defines what to do during start and destroy.

Create a new raw folder in the res directory and put A.mp3 in this directory.

In this way, when you click the start button, you can play the MP3 file. Click stop to stop playing.

I hope this article will be helpful to your Android program design.

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
分享
二维码
< <上一篇
下一篇>>