Intent intent = new Intent("com.moretv.broadcast");
Bundle bundle = new Bundle();
bundle.putString("Mode", mode);
bundle.putString("Data", data);
intent.putExtras(bundle);
sendBroadcast(intent);
字段 | 说明 |
Mode | 广播类型,不同类型的广播,Mode的指不同 |
Data | Data 的值为json字符串,不同的Mode类型对应的json格式可能不一样,也可能一样 |
类型 | 说明 |
playStart | 播放开始 |
playEnd | 播放结束 |
collectAdd | 收藏节目 |
collectRemove | 取消节目收藏 |
举例:
{
"Id": "xyjkhj5i5gtu",
"Title": "叛逃",
"Link_data": "page=detail&contentType=tv&sid=xyjkhj5i5gtu",
"Duration": 2614000,
"PlayTime": 85931,
"PicUrl": "http://pic.moretv.com.cn//20140318/20140318111050760.jpg",
"ContentType": "tv",
"Action": "moretv.action.applaunch"
}
变量名 | 参数说明 |
Id | 节目id |
Title | 节目名称 |
Link_data | 透传字段 |
Duration | 节目总时长 |
PlayTime | 播放时间 |
PicUrl | 海报图片地址 |
ContentType | 节目类型 |
Action | Intent启动MoreTV的action名称,缺省为 “moretv.action.applaunch” |
举例:
{
"Id": "xyjkhj5i5gtu",
"Title": "叛逃",
"Link_data": "page=detail&contentType=tv&sid=xyjkhj5i5gtu",
"PicUrl": "http://pic.moretv.com.cn//20140318/20140318111050760.jpg",
"ContentType": "tv",
"Action": "moretv.action.applaunch"
}
public class MoreTVPlayHistoryReciver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("com.moretv.broadcast")) {
// to do sth
}
}
}
<receiver android:name=".MoreTVPlayHistoryReciver">
<intent-filter>
<action android:name="com.moretv.broadcast"></action>
</intent-filter>
</receiver>