Android Open Source - AndroidConcurrency Poster

From Project

Back to project page AndroidConcurrency.


The source code is released under:

Apache License

If you think the Android project AndroidConcurrency listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

//w w  w  .  j av  a2  s  . co  m
import android.os.Handler;
import android.os.Message;
import android.os.RemoteException;
import android.util.Log;


 * @version $Revision: $
 * @author <a href="">G. Blake Meike</a>
class Poster extends IPostingService.Stub {
    private static final String TAG = "POSTER";

    private static final int POST_MESSAGE_ID = 42;

    static class PostHandler extends Handler {
        public void handleMessage(Message message) {
            switch (message.what) {
            case POST_MESSAGE_ID:
                Log.d(TAG, "post message");
                try {
                    PostArgs args = (PostArgs) message.obj;
                            ? MainActivity.STATUS_SUCCESS
                            : MainActivity.STATUS_FAIL);
                catch (RemoteException e) {
                    Log.d(TAG, "failed delivering response");

    private static class PostArgs {
        public final String text;
        public final IPostCompletionHandler hdlr;
        public PostArgs(String text, IPostCompletionHandler hdlr) {
            this.text = text;
            this.hdlr = hdlr;

    private PostHandler postHandler;

    public Poster(PostHandler postHandler) { this.postHandler = postHandler; }

    public void post(final String text, final IPostCompletionHandler hdlr) {
        Log.d(TAG, "posting: " + text);
                new PostArgs(text, hdlr)));

Java Source Code List