android音乐播放器框架实例
郑州app开发android音乐播放器框架实例。由于只是实现框架代码,布局设计上不太追求,所以只是放置了四个button,在这里由于篇幅有限,就不再展示了。直接展示java代码。
为乌鲁木齐等地区用户提供了全套网页设计制作服务,及乌鲁木齐网站建设行业解决方案。主营业务为网站建设、网站制作、乌鲁木齐网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
MainActivity.java
package cn.xhhkj.cyd;
import androidx.appcompat.app.AppCompatActivity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.bundle;
import android.os.Ibinder;
import android.view.View;
public class MainActivity extends AppCompatActivity {
private Myservice.Mybinder musicControl;
private Myconnection conn;
@Override
protected void onCreate(bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent myservice = new Intent(this,Myservice.class);
conn =new Myconnection();
bindService(myservice,conn,bIND_AUTO_CREATE);
startService(myservice);
}
public class Myconnection implements ServiceConnection{
@Override
public void onServiceConnected(ComponentName name, Ibinder service) {
musicControl = (Myservice.Mybinder) service;
}
@Override
public void onServiceDisconnected(ComponentName name) {
}
}
public void pre(View view) {
musicControl.callpre();
}
public void next(View view) {
musicControl.callnext();
}
public void play(View view) {
musicControl.callplay();
}
public void pause(View view) {
musicControl.callpause();
}
@Override
protected void onDestroy() {
super.onDestroy();
unbindService(conn);
}
}
Myservice.java
package cn.xhhkj.cyd;
import android.app.Service;
import android.content.Intent;
import android.media.MediaRecorder;
import android.os.binder;
import android.os.Ibinder;
import android.telephony.phoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import androidx.annotation.Nullable;
import java.io.IOException;
public class Myservice extends Service {
private static final String TAG = "服务是";
@Nullable
@Override
public Ibinder onbind(Intent intent) {
return new Mybinder();
}
public class Mybinder extends binder{
public void callpre(){
pre();
}
public void callnext(){
next();
}
public void callplay(){
play();
}
public void callpause(){
pause();
}
}
public void pre(){
Log.d(TAG,"上一首:郑州做个app多少钱");
}
public void next(){
Log.d(TAG,"下一首:郑州做个哪家好");
}
public void play(){
Log.d(TAG,"播放:app哪里比较正规");
}
public void pause(){
Log.d(TAG,"暂停:app分行业吗?");
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG,"开始");
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
super.onDestroy();
Log.d(TAG,"销毁");
}
}
新闻标题:android音乐播放器框架实例
本文路径:http://hbruida.cn/article/sccjep.html