Monday, April 22, 2013

[android help] How to update UI using thread in IPC mechanism of android


In one of my application project I have to get a data from JNI using AIDL interface. The AIDL interface is like below



interface IBiometricService {

int intFromJNI();

}


For above function I am getting data from JNI class. For the next step I am using service class to access data from AIDL stub,Its like below


public class BService extends Service{



@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
System.out.println("inside service");
td = new MyThread();
td.start();

}

@Override
public IBinder onBind(Intent intent) {

// TODO Auto-generated method stub

return bms;
}

@Override
public int intFromJNI() throws RemoteException {
// TODO Auto-generated method stub
data = BMService.intFromJNI();

}

private class MyThread extends Thread{


@Override
public void run() {
// TODO Auto-generated method stub
super.run();

try {
sleep((int)(Math.random() * 10000));

System.out.println("inside MyThread" +data);

} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}


}


In the above function intFromJNI() I am getting data but I need use thread mechanisam to access the data. How to use it in the above class and how to update data into UI.


Thanks Shiv



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...