广播接收websokcet发来数据后

整个用到的(主要用了handler,广播、service)实现图片下载、网页下面定时播放(网页、图片会下到本地,同时会按照图片的相应的ID名字生成一个xml文件保存周一到周六每天的播放图片)**但是这个如何检测当天是否已经过了昨天**

/**
* 广播接收类
*
*/
class MyReceiver extends BroadcastReceiver{

            private static final String TAG = "MyReceiver";
            @Override
            public void onReceive(Context context, Intent intent) {

                String action = intent.getAction();
                if (action.equals("mySend")) {


                    try {

                        // 接收到广播后更新 写入XML 文件
                        Document doc = OydXmlUtil.getXMLDocument();

                        String msg = intent.getStringExtra("msg");
                        mac = intent.getStringExtra("mac");

                        rootMap = new HashMap<String, String>();
                        rootMap.put("lastupdate", OydSystemUtil.getCurrentDate());
                        rootMap.put("mac", mac);
                        rootMap.put("userid", userid);
                        // 更新Root节点
                        OydXmlUtil.UpdateRootNodeAttr(rootMap, doc);
                        JSONArray jsonArra = new JSONArray(msg);
                        Toast t = Toast.makeText(context, "当前Handler:."+ getHandler(), Toast.LENGTH_LONG);
                        t.setGravity(Gravity.TOP, 0, 0);// 方便录屏,将土司设置在屏幕顶端
                        t.show();
                        Map<String, String> map = null;
                        String day = "";
                        String week = "";
                        // 周循环
                        for(int j=1;j<=7;j++){
                           //集合循环
                           switch (j){             
                            case 1: day = "monday";OydXmlUtil.deleteNodes(doc, day);
                                break;
                            case 2: day = "tuesday";OydXmlUtil.deleteNodes(doc, day);
                                break;
                            case 3: day = "wednesday";OydXmlUtil.deleteNodes(doc, day);
                                break;
                            case 4: day = "thursday";OydXmlUtil.deleteNodes(doc, day);
                                break;
                            case 5: day = "friday";OydXmlUtil.deleteNodes(doc, day);
                                break;
                            case 6: day = "saturday";OydXmlUtil.deleteNodes(doc, day);
                                break;
                            case 7: day = "sunday";OydXmlUtil.deleteNodes(doc, day);
                                break;

                           }
                            for (int i = 0; i < jsonArra.length() - 1; i++) {

                                JSONObject json = jsonArra.getJSONObject(i);

                                week = json.getString("week");

                                if (j == Integer.parseInt(week)) {
                                    map = new HashMap<String, String>();
                                    map.put("time", json.getString("time"));
                                    map.put("proName", json.getString("proName"));
                                    // 插入项目节点
                                    OydXmlUtil.addChildNode(doc, day, map);
                                }
                            }

                        }
                        Message msgloadxml = handler.obtainMessage();
                        msgloadxml.what = 8;//7
                        handler.sendMessage(msgloadxml);                    

                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }





        }


    }

2个回答

你们都是默默看一眼,然后心里说声。事不关己高高挂起?

这里看来是废了。。。。。。。。。。。。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐