I have to develope a simple chat application in android. I have to use MySQL as my backend database.
But my problem is: When I am posting data on to the server, there may be too many post happends in my app. So that, duplicate records should be inserted in my server database. For posting data on a server, I have to use LoopJ AndroidAsyncHttp. Also I have to place my code inside the runnable thread. My Problem occurs in the chat screen Page.
public class UMService extends Service {
@override
public void onCreate()
{
super.onCreate();
HandlerThread ht = new HandlerThread("nonUiThread");
ht.start();
final Handler mHandler = new Handler(ht.getLooper());
Runnable sendUpdatesToUI = new Runnable() {
public void run() {
syncSQLiteMySQLDB();
mHandler.postDelayed(this, 1000);
}
};
mHandler.postDelayed(sendUpdatesToUI, 1000)
}