Posts

Showing posts with the label communication

Communicate with Activity from Service (LocalService) - Android Best Practices

Image
Clash Royale CLAN TAG #URR8PPP Communicate with Activity from Service (LocalService) - Android Best Practices Common scenario - Activity with a background Service to poll server. The Service will run periodically via AlarmManager and also perform tasks for the Activity (user hits a button, go fetch something from server). I'd like to know the best practices here. I think the best design would be the Android LocalService example: http://developer.android.com/reference/android/app/Service.html#LocalServiceSample However in the example the Activity has a reference to the activity mBoundService but there is no reverse connection ( the Service has no way to call the Activity ). mBoundService What is the best way for the Service to call the Activity? Do I use Intents, BroadcastReceivers, Messages? How? 3 Answers 3 I think the best design would be the Android LocalService example: http://developer...

java readInt() on server doesn't get the good int

Image
Clash Royale CLAN TAG #URR8PPP java readInt() on server doesn't get the good int I'm implementing a "little" client/server app, like a Cloud. The problem is: I'm new to Java. So I've learned it a bit fast, and same for client/server communication, database, frames, threads. I'm pretty sure my code won't be the best one, but the fact is: I have to use Java, and I have to do this fast. I won't try to optimize it, I just need it to work. I have already implemented a lot, so I won't give all the code here, just explain what happens before my problem: The main prog on client side opens a login frame. The client can register or login. Registration is working well, so let's say he logs in. If authentication works, that opens another frame, with "browse" and "upload" options. The idea is, he browse a file and then upload it. When he clicks on upload, it should call the upload function, which will send a byte[2] array to the serv...