Having trouble with while updating Android UI after reciving photon events ... please help

dear community ,

i am using android sdk , and have created an app to recive published events from photon device ,i am able to recive events but recived data is not updating in my android main UI . i am attaching the main code snippet .
in code ONSuccess section is executing only once .
please help . if need more info please ask …

TextView txtcurr,txttemp,txtmode,valuetemp,valuecurr,valuemode,valuedist,txtdist;
    long subscriptionId;
    GaugeView socgauge;
    String variable="-1,-1,-1,-1,-1";
    DeluxeSpeedView raySpeedometer;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(activity_fullscreen);
        ParticleCloudSDK.init(FullscreenActivity.this);
        raySpeedometer = (DeluxeSpeedView) findViewById(R.id.DeluxeSpeedView);
        raySpeedometer.setWithEffects(false); //def : true
        raySpeedometer.setSpeedBackgroundColor(Color.BLACK);
        socgauge= (GaugeView)  findViewById(R.id.gauge);
        txtcurr = (TextView) findViewById(R.id.txtcurr);
        txtmode = (TextView) findViewById(R.id.txtmode);
        txttemp = (TextView) findViewById(R.id.txttemp);
        txtdist = (TextView) findViewById(R.id.txtdist);
        valuecurr = (TextView) findViewById(R.id.valuecurr);
        valuemode = (TextView) findViewById(R.id.valuemode);
        valuetemp = (TextView) findViewById(R.id.valuetemp);
        valuedist = (TextView) findViewById(R.id.valuedist);
        Typeface lcdTypeface = Typeface.createFromAsset(getAssets(), "fonts/digital7.ttf");
        txtcurr.setTypeface(lcdTypeface);
        txtmode.setTypeface(lcdTypeface);
        txttemp.setTypeface(lcdTypeface);
        valuecurr.setTypeface(lcdTypeface);
        valuetemp.setTypeface(lcdTypeface);
        valuemode.setTypeface(lcdTypeface);
        txtdist.setTypeface(lcdTypeface);
        valuedist.setTypeface(lcdTypeface);
        socgauge.setValue(0);
        valuedist.setText("0");
        valuecurr.setText("0");
        valuetemp.setText("0");
        valuemode.setText("0");
        raySpeedometer.speedTo(0);

        Async.executeAsync(ParticleCloudSDK.getCloud(), new Async.ApiWork<ParticleCloud, String>() {
            @Override
            public String callApi(ParticleCloud ParticleCloud) throws ParticleCloudException, IOException {

                subscriptionId = ParticleCloudSDK.getCloud().subscribeToDeviceEvents("temp", "3d001047343432313xx",

                        new ParticleEventHandler() {
                            public void onEvent(String eventName, ParticleEvent event) {
                                variable = event.dataPayload;
                                Log.i("tag", "Received event with payload: " + variable + " " + eventName);

                            }

                            public void onEventError(Exception e) {
                                Log.e("some tag", "Event error: ", e);
                                variable = "-1,-1,-1,-1,-1";

                            }
                        }
                );

                return variable;
            }

            @Override
            public void onSuccess(String i) {
                String[] datavalues = i.split(",");
                socgauge.setValue(Float.parseFloat(datavalues[0]));
                valuedist.setText("22");
                valuecurr.setText(datavalues[2]);
                valuetemp.setText(datavalues[3]);
                valuemode.setText(datavalues[4]);
                raySpeedometer.speedTo(0);
                Log.i("tag", "SOC:" + datavalues[0]);
                Log.i("tag", "volt:" + datavalues[1]);
                Log.i("tag", "curr:" + datavalues[2]);
                Log.i("tag", "temp:" + datavalues[3]);
                Log.i("tag", "mode:" + datavalues[4]);

            }

            @Override
            public void onFailure(ParticleCloudException e) {
                e.printStackTrace();
                Log.e("some tag","error", e);
            }
        });
    }

onSuccess will be called only once because it is triggered upon successfully subscribing to device events as a result of calling ‘subscribeToDeviceEvents’ API. What’s happening is that when you call this API you also provide a handler for any events that are caught by the listener. When the listener catches an event it call ‘onEvent’ method of your handler. It is this ‘onEvent’ method that would be called repeatedly. The variable that you are returning from onSuccess has got nothing to do with the execution of ‘onEvent’ method.

Since onEvent method is being called by the event listener that is running on a non-ui thread, you cannot update your UI from within onEvent method. To update your UI, you can use a UI thread handler object. You can use UI thread handler to post messages from non-ui thread to your ui thread and you can then update your UI inside ‘onHandleMessage’ method of your UI thread handler.

Here’s a code example that you can use to do it

    private final Handler _handler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        if(msg.what == "MyEvent") {
            Bundle bundle = msg.getData();              
            String payloadData = bundle.getString("EventPayload");
            TextView tv = (TextView) MainActivity.this.findViewById(R.id.event_textview);
            tv.setText(payloadData);
        }
    }
};

    Async.executeAsync(ParticleCloudSDK.getCloud(), new Async.ApiWork<ParticleCloud, Long>() {

        @Override
        public Long callApi(ParticleCloud particleCloud) throws ParticleCloudException, IOException {
            return ParticleCloudSDK.getCloud().subscribeToDeviceEvents(
                    null,
                    "3d001047343432313xx",
                    new ParticleEventHandler() {
                        public void onEvent(String eventName, ParticleEvent event) {                                
                            Message msg = _handler.obtainMessage("MyEvent");
                            Bundle bundle = new Bundle();
                            bundle.putString("EventPayload", event.dataPayload);
                            msg.setData(bundle);
                            _handler.sendMessage(msg);
                        }

                        public void onEventError(Exception e) {
                            Log.e("some tag", "Event error: ", e);
                        }
                    });

        }

        @Override
        public void onSuccess(Long subId) {
            _subscriptionId = subId;
            Toaster.l(MainActivity.this, "Subscribed to device events successfully.");
        }

        @Override
        public void onFailure(ParticleCloudException exception) {
            Toaster.l(MainActivity.this, "Error subscribing to device events.");
        }
    });

Hope this makes sense.