public class MusicService extends Service
{
//MediaPlayer对象
private MediaPlayer player; public IBinder onBind(Intent arg0)
{
return null;
} public void onStart(Intent intent, int startId)
{
super.onStart(intent, startId);
//这里可以理解为装载音乐文件
player = MediaPlayer.create(this, R.raw.test);
//开始播放
player.start();
} public void onDestroy()
{
super.onDestroy();
//停止音乐-停止Service
player.stop();
}}
onBind这一行是什么总用啊;
还有onstart怎么用啊??谢谢了啊
{
//MediaPlayer对象
private MediaPlayer player; public IBinder onBind(Intent arg0)
{
return null;
} public void onStart(Intent intent, int startId)
{
super.onStart(intent, startId);
//这里可以理解为装载音乐文件
player = MediaPlayer.create(this, R.raw.test);
//开始播放
player.start();
} public void onDestroy()
{
super.onDestroy();
//停止音乐-停止Service
player.stop();
}}
onBind这一行是什么总用啊;
还有onstart怎么用啊??谢谢了啊
解决方案 »
- Windowssp3+eclipse3.7.2安装adt16时有如下错误,大神求指导
- RIM为吸引Android开发者出新招
- android4.2不支持侧滑之后对ListView的点击监听
- 土木小白求助
- 请教activity的问题
- 我想知道,在模拟器能运行,真机不能运行的情况有哪些
- Qt for Android 在工程项目->构建下 ,出现不兼容的构建
- android怎么从后台接口获取base64文件
- 大神求解答,这个工作原理是什么,硬件怎么配置,怎么编程
- 请问如何把Recyclerview嵌套进NavigationView当中?
- ProgressBar 如何加文字
- 【Android 游戏开发】-- 仿捕鱼达人
context.startService() ->onCreate()- >onStart()->Service running
context.stopService() | ->onDestroy() ->Service stop 使用使用context.bindService()启动Service会经历:
context.bindService()->onCreate()->onBind()->Service running
onUnbind() -> onDestroy() ->Service stop