//创建一个Intent对象
RemoteViews remoteViews=new RemoteViews(context.getPackageName(),R.layout.appwidget_music);
//前一首歌
Intent intent=new Intent(context,MusicPlayService.class);
Bundle bundle=new Bundle();
bundle.putString("action","prev");
intent.putExtras(bundle);
// 创建一个PendingIntent对象
PendingIntent pendingIntent=PendingIntent.getService(context,0,intent,
PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.prevMusicImage,pendingIntent);
//下一首
intent=new Intent(context,MusicPlayService.class);
bundle=intent.getExtras();
bundle=new Bundle();
bundle.putString("action","next");
intent.putExtras(bundle);
pendingIntent=PendingIntent.getService(context,0,intent,0);
remoteViews.setOnClickPendingIntent(R.id.nextMusicImage,pendingIntent);
//播放或暂停
intent=new Intent(context,MusicPlayService.class);
bundle=new Bundle();
bundle.putString("action","playOrPause");
intent.putExtras(bundle);
pendingIntent=PendingIntent.getService(context,0,intent,0);
remoteViews.setOnClickPendingIntent(R.id.playOrPauseImage,pendingIntent);我想实现用appWidget 控制MP3播放, 但这样出来的 3个pendingIntent 用equls都是相等的,service中只能获得action 为prev 其它两个值都无法获得,那该怎么给每个button绑定 pending Intent呢
解决方案 »
- 编译SDK相关问题第一步: 源码获取
- ImageView缩放后,bitmap尺寸
- Android程序员目前全国各地工资待遇怎么样?
- The specified child already has a parent
- 图像识别主要用到哪些技术
- android 发送短信问题
- 有没有办法制作固定宽与高的Dialog?
- 请问:ListView只能放到ListActivity?
- android intent 跳转问题
- 获取 Android 源代码,总是提示:fatal: HTTP request failed???有什么技巧、或设置啊
- 一个界面问题
- android中多个case一起测的时候,Test run failed: Process crashed.
..好像是这样吧...望指正~~