Android Umeng PushService
Public class PushServices extends UmengBaseIntentService {private PushAgent mPushAgent; private vertex service; private ScheduledFuture scheduledFuture; private int I = 1; private Handler handler = new Handler () {public void handleMessage (android. OS. message msg) {Toast. makeText (getApplicationContext (), "scheduled:" + msg. what, Toast. LENGTH_SHORT ). show () ;};}; @ Overridepublic void onCreate (){// TODO Auto-generated method stubsuper. onCreate (); try {timeTask ();} catch (InterruptedException e) {// TODO Auto-generated catch blocke. printStackTrace ();} catch (ExecutionException e) {// TODO Auto-generated catch blocke. printStackTrace () ;}/ ***** @ Title: timeTask * @ Description: TODO Scheduled Update task, one set of scheduled uploads * @ return void */public void timeTask () throws InterruptedException, ExecutionException {// TODO Aut O-generated method stubif (service = null) {service = Executors. newScheduledThreadPool (1);} if (scheduledFuture = null) {scheduledFuture = service. scheduleAtFixedRate (new UploadData (), 0, 5, TimeUnit. SECONDS) ;}@ Overrideprotected void onMessage (Context context, Intent intent) {// TODO Auto-generated method stubsuper. onMessage (context, intent); try {String message = intent. getStringExtra (BaseConstan Ts. MESSAGE_BODY); if (StringUtils. isEmpty (message) {return;} UMessage msg = new UMessage (new JSONObject (message); if (msg! = Null) {mPushAgent = PushAgent. getInstance (context); UmengMessageHandler messageHandler = new UmengMessageHandler (); messageHandler. dealWithNotificationMessage (context, msg); umengnotifclickclickhandler icationclickhandler = new umengnotifnotifclickhandler (); mPushAgent. setMessageHandler (messageHandler); mPushAgent. setnotifclickclickhandler (icationicationclickhandler); UTrack. getInstance (contex T ). trackMsgClick (msg) ;}} catch (Exception e) {}}@ Overridepublic void onDestroy () {// TODO Auto-generated method stubsuper. onDestroy (); if (scheduledFuture! = Null) {scheduledFuture. cancel (true); scheduledFuture = null ;}// upload task public class UploadData implements Runnable {@ Overridepublic void run () {// TODO Auto-generated method stubi ++; message message = Message. obtain (); message. what = I; handler. sendMessage (message );}}}