0

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)
} 
Suriyaa
  • 2,222
  • 2
  • 25
  • 44
  • *"My Problem occurs in the chat screen Page"* what is the problem? including your logcat would be very helpful – Randyka Yudhistira Feb 24 '15 at 09:38
  • actually chat screen works properly,but the function syncSQLiteMySQLDB(),posting too many records in my server.The body of the syncSQLiteMySQLDB() is – muraleedharan Feb 24 '15 at 09:52
  • show me your syncSQLiteMySQLDB(). put it in your question – Randyka Yudhistira Feb 24 '15 at 09:55
  • void syncSQLiteMySQLDB() { String Url = prop_common.get_url()+ page.sendrequestpage; AsyncHttpClient client = new AsyncHttpClient(); RequestParams params = new RequestParams(); if(localstoragehandler.dbSync_count()!= 0) { params.put("requestJSON",localstoragehandler.composeJSONfromSQLite()); client.post(Url,params,new AsyncHttpResponseHandler() { @override public void onSuccess(int statuscode, Header[] headers, byte[] { } } } – muraleedharan Feb 24 '15 at 09:57
  • you need to flag your records after sync them to server. in onSuccess method – Randyka Yudhistira Feb 24 '15 at 10:06

0 Answers0