I’m new in Android and even Java.
I have to save and read message in an activity using another class “Utility”. And it will cause ANR, I heard I have to do that kind of things in a separate thread.
this is my code:
Utility.save(this, message, lsn);
Message tmp = Utility.read(this, lsn);
and I tried this:
final ProgressDialog progressDialog = ProgressDialog.show(
this, "Please wait....", "Here your message");
new Thread(new Runnable() {
public void run() {
Utility.save(this, message, lsn);
Message tmp = Utility.read(this, lsn);
progressDialog.dismiss();
}
}).start();
and as you can imagine, there is no way go just like this.
Do I need to use aidl?
Thank you guys.
what you should probably do is use
AsyncTaskwhich is the Android way of multi threading in apps.try reading in the android developers on this: http://android-developers.blogspot.co.il/2010/07/multithreading-for-performance.html