com.baidu.android.pushservice.PushManager Java Examples
The following examples show how to use
com.baidu.android.pushservice.PushManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MyBroadcastReceiver.java From Huochexing12306 with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){ //开机启动激活服务 openAlarm(context); delayRequestCheckBgdServiceStatus(context); }else if (intent.getAction().equals(ACTION_BGD_SERVICE)){ Intent myIntent = new Intent(context, BgdService.class); context.startService(myIntent); }else if (intent.getAction().equals(CONNECTIVITY_ACTION)){ if (HttpUtil.isNetworkConnected(context)){ //绑定百度云推送 if(!PushManager.isPushEnabled(context)){ PushManager.startWork(context, PushConstants.LOGIN_TYPE_API_KEY, MyApp.API_KEY); } } } }
Example #2
Source File: ChatRoomFragment.java From Huochexing12306 with Apache License 2.0 | 6 votes |
/** * 初始化数据 */ private void initData() { trainId = cContent.getTrainNum(); chatRoomTag = cContent.getPushTag(); messageDB = MyApp.getInstance().getMessageDB(); userInfoSPUtil = MyApp.getInstance().getUserInfoSPUtil(); //初始化表情文字 mFacemap = TT.getFaceMap(); faceKeysList.addAll(mFacemap.keySet()); messageAdapter = new MessageAdapter(getActivity(), messageDB.getMessage(trainId,MsgPagerNum), mFacemap); //检查push服务是否开启 if(!PushManager.isPushEnabled(getActivity())){ PushManager.startWork(getActivity(), PushConstants.LOGIN_TYPE_API_KEY, MyApp.API_KEY); } }
Example #3
Source File: MainActivity.java From Huochexing12306 with Apache License 2.0 | 6 votes |
public void quit() { MobclickAgent.onKillProcess(this); MyApp myApp = ((MyApp)getApplication()); L.i("isAntiTheftServiceStarted:" + myApp.isAntiTheftServiceStarted); L.i("isBgdService2Started:" + myApp.isBgdService2Started); if (myApp.isAntiTheftServiceStarted || myApp.isBgdService2Started){ MainActivity.this.finish(); }else{ Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startMain); System.exit(0); } //确认是否在退出后取消接收聊天信息 SettingSPUtil setSP = MyApp.getInstance().getSettingSPUtil(); if (!setSP.isChatReceiveMsgAlways()){ PushManager.stopWork(getApplicationContext()); } }
Example #4
Source File: BaiduPushTagsHelper.java From Huochexing12306 with Apache License 2.0 | 5 votes |
/** * 更新baiduPush服务端的 tags * @param currentTags 当前服务端的tags */ public void updateTags(Context context , List<String> currentTags) { List<String> newTags = getTagsList(); //向服务器更新 if(currentTags==null||currentTags.size()==0){ //没有tag直接设置 if(newTags.size()!=0){ PushManager.setTags(context,newTags); } }else{ //生成需要添加的tag列表和需要删除的tag列表 List<String> rmTags = currentTags; //先假设服务器中的tag都需要删除 List<String> addTags = new ArrayList<String>(); for (String tag : newTags) { if(rmTags.contains(tag)){ //服务器已经包含此tag rmTags.remove(tag); //仍需要此tag所以将其从此删除列表中移除 }else{ addTags.add(tag); } } if(rmTags.size()!=0){ PushManager.delTags(context,rmTags); } if(addTags.size()!=0){ PushManager.setTags(context,addTags); } } //查看当前tag--log输出 PushManager.listTags(context); }
Example #5
Source File: GosPushManager.java From GOpenSource_AppKit_Android_AS with MIT License | 5 votes |
public void bDPush() { final String BDPushAppKey = GosDeploy.setBaiDuPushAppKey(); if (TextUtils.isEmpty(BDPushAppKey) || BDPushAppKey.contains("your_bpush_api_key")) { GosBaseActivity.noIDAlert(context, R.string.BDPushAppID_Toast); } else { PushManager.startWork(context, PushConstants.LOGIN_TYPE_API_KEY, BDPushAppKey); PushSettings.enableDebugMode(context, true); } }
Example #6
Source File: GosPushManager.java From Gizwits-SmartBuld_Android with MIT License | 5 votes |
public void bDPush() { String BDPushAppKey = GosDeploy.setBaiDuPushAppKey(); if (TextUtils.isEmpty(BDPushAppKey) || BDPushAppKey.contains("your_bpush_api_key")) { Toast.makeText(context, R.string.BDPushAppID_Toast, 2000).show(); } else { PushManager.startWork(context, PushConstants.LOGIN_TYPE_API_KEY, BDPushAppKey); } }
Example #7
Source File: GosPushManager.java From gokit-android with MIT License | 5 votes |
public void bDPush() { final String BDPushAppKey = GosDeploy.setBaiDuPushAppKey(); if (TextUtils.isEmpty(BDPushAppKey) || BDPushAppKey.contains("your_bpush_api_key")) { GosBaseActivity.noIDAlert(context, R.string.BDPushAppID_Toast); } else { PushManager.startWork(context, PushConstants.LOGIN_TYPE_API_KEY, BDPushAppKey); PushSettings.enableDebugMode(context, true); } }
Example #8
Source File: BaiduPushTagsHelper.java From Huochexing12306 with Apache License 2.0 | 4 votes |
/** * 设置tag * @param tag 一条tag */ public void setTag(Context context,String tag) { List<String> tags = new ArrayList<String>(); tags.add(tag); PushManager.setTags(context,tags); }
Example #9
Source File: BaiduPushTagsHelper.java From Huochexing12306 with Apache License 2.0 | 4 votes |
/** * 删除tag * @param tag 一条tag */ public void deleteTag(Context context,String tag) { List<String> tags = new ArrayList<String>(); tags.add(tag); PushManager.delTags(context, tags);; }
Example #10
Source File: TrainInfoUtil.java From Huochexing12306 with Apache License 2.0 | 4 votes |
public static int updateUserTrainList(SQLiteDatabase db) throws JSONException, ClientProtocolException, IOException{ String strUrl = "http://huochexing.duapp.com/server/user_train.php"; String strJson = "{\"requestType\":\"getTravels\",\"uid\":\"" + MyApp.getInstance().getUserInfoSPUtil().getUId() + "\"}"; HttpUtil httpUtil = new HttpUtil(); if (httpUtil.post(strUrl, strJson)) { JSONObject jsonObj = new JSONObject( (String) httpUtil.getResponseStr()); int intResultCode = jsonObj .getInt(HttpUtil.RESULT_CODE); switch (intResultCode) { case HttpUtil.MSG_RECEIVE_FAIL: return 0; case HttpUtil.MSG_RECEIVE_SUCCESS: JSONArray jsonArray = jsonObj .getJSONArray("travels"); db.delete( "UserTrainB", "U_id=?", new String[] { String.valueOf(MyApp .getInstance().getUserInfoSPUtil() .getUId()) }); for (int i = 0; i < jsonArray.length(); i++) { JSONObject subObj = jsonArray.getJSONObject(i); ContentValues cv = new ContentValues(); cv.put("ServerId", subObj.getString("serverId")); cv.put("U_id", MyApp.getInstance() .getUserInfoSPUtil().getUId()); cv.put("T_id", subObj.getString("trainNum")); cv.put("TravelName", subObj.getString("travelName")); cv.put("StartStation", subObj.getString("startStation")); cv.put("EndStation", subObj.getString("endStation")); cv.put("R_Date", subObj.getString("r_Date")); cv.put("startLongitude", subObj.getString("startLongitude")); cv.put("startLatitude", subObj.getString("startLatitude")); cv.put("receiveMsg", subObj.getInt("receiveMsg")); cv.put("receivedReminder", subObj.getInt("receivedReminder")); cv.put("isRepeatReminder", subObj.getInt("isRepeatReminder")); cv.put("StartTime", subObj.getString("startTime")); cv.put("EndTime", subObj.getString("endTime")); cv.put("T_StartTime", subObj.getString("t_StartTime")); cv.put("UserStatus", subObj.getString("userStatus")); db.insert("UserTrainB", null, cv); } // 更新车次后 设置是否接收聊天信息 PushMessageReceiver .setListTagsAction(PushMessageReceiver.UPDATE_TAGS); PushManager.listTags(MyApp.getInstance()); // 调用listTags()后 // 会回调PushMessageReceiver中的onListTags方法 break; } } else { return 0; } return 1; }
Example #11
Source File: WelcomeAty.java From Huochexing12306 with Apache License 2.0 | 4 votes |
@SuppressLint("WorldReadableFiles") @Override public void run() { //确定已复制数据库 MyDatabase myDB = new MyDatabase(this); myDB.closeDB(); // setSP.setTravelFirstShow(true); try { if (HttpUtil.isNetworkConnected(this)) { // 绑定百度云推送 PushManager .startWork(this.getApplicationContext(), PushConstants.LOGIN_TYPE_API_KEY, MyApp.API_KEY); } //移动历史离线文件到SD卡 updateHisOfflineFile(); //初始化抢票监控状态 String strMFilesPath = MyApp.getInstance().getPathBaseRoot(StoreValue.MONITOR_INFOS_FILE); @SuppressWarnings("unchecked") List<MonitorInfo> lstMInfos = (List<MonitorInfo>) PersistentUtil.readObject(strMFilesPath); if (lstMInfos != null && lstMInfos.size() != 0){ for (MonitorInfo mInfo : lstMInfos) { mInfo.setRunning(false); mInfo.setStatus(BgdService2.STATUS_STOPED); } PersistentUtil.writeObject(lstMInfos, strMFilesPath); } Thread.sleep(1000); //检查是否是第一次登录 if (setSP.isFirstUse()){ startActivity(new Intent(WelcomeAty.this, LoginAty.class)); }else{ launtchDefaultAty(); } finish(); } catch (Exception e) { e.printStackTrace(); } }