JAVA Android: Logging in... (freezes) -
i have no clue why app freezes while tries connect tcp server. establish connection know that, because signs me off other messenger when connect it, freezes says "logging in.."
07-01 05:37:55.297: e/androidruntime(280): fatal exception: main 07-01 05:37:55.297: e/androidruntime(280): java.lang.runtimeexception: unable provider com.android.providers.contacts.calllogprovider: java.lang.illegalstateexception: error upgrading database version 309 07-01 05:37:55.297: e/androidruntime(280): @ android.app.activitythread.installprovider(activitythread.java:4509) 07-01 05:37:55.297: e/androidruntime(280): @ android.app.activitythread.installcontentproviders(activitythread.java:4281) 07-01 05:37:55.297: e/androidruntime(280): @ android.app.activitythread.handlebindapplication(activitythread.java:4237) 07-01 05:37:55.297: e/androidruntime(280): @ android.app.activitythread.access$3000(activitythread.java:125) 07-01 05:37:55.297: e/androidruntime(280): @ android.app.activitythread$h.handlemessage(activitythread.java:2071) 07-01 05:37:55.297: e/androidruntime(280): @ android.os.handler.dispatchmessage(handler.java:99) 07-01 05:37:55.297: e/androidruntime(280): @ android.os.looper.loop(looper.java:123) 07-01 05:37:55.297: e/androidruntime(280): @ android.app.activitythread.main(activitythread.java:4627) 07-01 05:37:55.297: e/androidruntime(280): @ java.lang.reflect.method.invokenative(native method) 07-01 05:37:55.297: e/androidruntime(280): @ java.lang.reflect.method.invoke(method.java:521) 07-01 05:37:55.297: e/androidruntime(280): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:868) 07-01 05:37:55.297: e/androidruntime(280): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:626) 07-01 05:37:55.297: e/androidruntime(280): @ dalvik.system.nativestart.main(native method) 07-01 05:37:55.297: e/androidruntime(280): caused by: java.lang.illegalstateexception: error upgrading database version 309 07-01 05:37:55.297: e/androidruntime(280): @ com.android.providers.contacts.contactsdatabasehelper.onupgrade(contactsdatabasehelper.java:1507) 07-01 05:37:55.297: e/androidruntime(280): @ android.database.sqlite.sqliteopenhelper.getwritabledatabase(sqliteopenhelper.java:108) 07-01 05:37:55.297: e/androidruntime(280): @ com.android.providers.contacts.contactsdatabasehelper.getwritabledatabase(contactsdatabasehelper.java:2507) 07-01 05:37:55.297: e/androidruntime(280): @ com.android.providers.contacts.calllogprovider.oncreate(calllogprovider.java:79) 07-01 05:37:55.297: e/androidruntime(280): @ android.content.contentprovider.attachinfo(contentprovider.java:733) 07-01 05:37:55.297: e/androidruntime(280): @ android.app.activitythread.installprovider(activitythread.java:4506) 07-01 05:37:55.297: e/androidruntime(280): ... 12 more 07-01 05:37:55.328: w/activitymanager(59): process android.process.acore has crashed many times: killing! 07-01 05:37:55.328: w/activitymanager(59): unable launch app com.android.providers.contacts/10009 provider call_log: launching app became null 07-01 05:37:55.328: e/activitythread(114): failed find provider info call_log
i have looked @ these logs trying figure out problem nothing has worked out on favor yet... causing app being frozen?
edit:
import java.io.datainputstream; import java.io.dataoutputstream; import java.io.ioexception; import java.net.socket; public class connectionn extends thread implements xfireobserver { private datainputstream in = null; private dataoutputstream out = null; private byte[] buffer; private string username, password, nickname, statustext = "online"; private boolean runthread = true; public connectionn() { eventmanager.addobserver(this); } /** * connect xfire using username , password provided in constructor. */ public void connect(string username, string password) { this.username = username; this.password = password; try { if (!runthread) return; socket s = new socket("cs.xfire.com", 25999); in = new datainputstream(s.getinputstream()); out = new dataoutputstream(s.getoutputstream()); login(); } catch (exception e) { e.printstacktrace(); disconnect(); } } public void disconnect() { eventmanager.removeobserver(this); runthread = false; try { out.write(new byte[] { 0, 0, 0, 0 }); // sabotage stream } catch (ioexception ioe) { ioe.printstacktrace(); } { try { out.close(); in.close(); } catch (ioexception ioe) { ioe.printstacktrace(); } friendmanager.getinstance().cleanup(); eventmanager.fireevent(new datalessevent(xfireevent.xf_offline)); } } public void run() { setname("xfire reader thread"); while(runthread) { readbytes(); debug(buffer); switch(buffer[0] & 0xff) { case 0x80: // salt saltpacket sp = new saltpacket(buffer); loginpacket lp = new loginpacket(username, password, sp.getsalt()); write(lp.getbytes()); break; case 0x81: // auth failed disconnect(); eventmanager.fireevent(new datalessevent(xfireevent.xf_loginfail)); break; case 0x82: // loginreply loginreplypacket lrp = new loginreplypacket(buffer); nickname = lrp.getnickname(); break; case 0x83: // friendslist new friendslistpacket(buffer); break; case 0x84: // friend online new friendstatuspacket(buffer); break; case 0x85: // receive message receivemessagepacket rmp = new receivemessagepacket(buffer); if (rmp.getmessagetype() == receivemessagepacket.msgtype_im) { ackimpacket amp = new ackimpacket(rmp.getsid(), rmp.getimindex()); write(amp.getbytes()); } break; case 0x87: // friend in game new friendgamepacket(buffer); break; case 0x91: // disconnected reason disconnect(); eventmanager.fireevent(new datalessevent(xfireevent.xf_dcreason)); break; case 0x9a: // friend status text new friendstatustextpacket(buffer); break; case 0xac: new screenshotspacket(buffer); break; } } } private void login() { // initialize connection 'ua01' packet write("ua01".getbytes()); system.out.println("asd"); // send version packet versionpacket vp = new versionpacket(); write(vp.getbytes()); // start reader thread try{ start(); }catch(exception threade){ system.out.println("thread not called!"); } } /** * returns nickname set xfire user. * @return current nickname. */ public string getnickname() { return nickname; } /** * sets new nickname xfire user. * @param nick nickname set. */ public void setnickname(string nickname) { changenickpacket cnp = new changenickpacket(nickname); write(cnp.getbytes()); this.nickname = nickname; } public string getstatustext() { return statustext; } public void setstatustext(string statustext) { changestatustextpacket cstp = new changestatustextpacket(statustext); write(cstp.getbytes()); this.statustext = statustext; } public string getusername() { return username; } public void handleevent(xfireevent event) { switch(event.geteventtype()) { case xfireevent.xf_sendim: sendimevent e = (sendimevent)event; sendimpacket sip = new sendimpacket(e.getsid(), e.getimindex(), e.getmessage()); write(sip.getbytes()); return; case xfireevent.xf_reqinfo: friend f = ((friendevent)event).getfriend(); requestinfopacket rip = new requestinfopacket(f.getuserid()); write(rip.getbytes()); return; } } /* * i/o , debugging methods */ private void readbytes() { try { byte[] numbytes = new byte[2]; in.read(numbytes, 0, 2); int low = numbytes[0] & 0xff, high = numbytes[1] & 0xff; int len = (0x00 | low | (high << 8)) - 2; if (len <= 0) { buffer = new byte[] { 0 }; return; } buffer = new byte[len]; in.read(buffer, 0, len); } catch (ioexception ioe) { ioe.printstacktrace(); disconnect(); } } public void write(byte[] bs) { try { out.write(bs); } catch (ioexception ioe) { ioe.printstacktrace(); disconnect(); } } private static void debug(byte[] bs) { (byte b : bs) { system.out.print(string.format("%02x", b) + " "); } system.out.println(); } }
Comments
Post a Comment