Example usage for twitter4j Twitter retweetStatus

List of usage examples for twitter4j Twitter retweetStatus

Introduction

In this page you can find the example usage for twitter4j Twitter retweetStatus.

Prototype

Status retweetStatus(long statusId) throws TwitterException;

Source Link

Document

Retweets a tweet.

Usage

From source file:au.edu.anu.portal.portlets.tweetal.servlet.TweetalServlet.java

License:Apache License

public void retweet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/json");
    PrintWriter out = response.getWriter();

    String userToken = request.getParameter("u");
    String userSecret = request.getParameter("s");
    long statusId = Long.parseLong(request.getParameter("d"));

    log.debug("statusId: " + statusId);

    Twitter twitter = twitterLogic.getTwitterAuthForUser(userToken, userSecret);
    if (twitter == null) {
        // no connection
        response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
        return;/*from ww w  .ja  v  a 2  s. com*/
    }

    try {
        Status status = null;

        // update user status
        status = twitter.retweetStatus(statusId);
        if (status == null) {
            log.error("Status is null.");
            // general error
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }

        JSONObject json = new JSONObject();
        JSONObject statusJSON = getStatusJSON(twitter, status);

        // return as an array even though only it contains only one element,
        // so we can reuse the same Trimpath template (Denny)
        JSONArray statusList = new JSONArray();
        statusList.add(statusJSON);
        json.put("statusList", statusList);

        if (log.isDebugEnabled()) {
            log.debug(json.toString(2));
        }

        out.print(json.toString());

    } catch (TwitterException e) {
        log.error("GetTweets: " + e.getStatusCode() + ": " + e.getClass() + e.getMessage());

        if (e.getStatusCode() == 401) {
            // invalid credentials
            response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
        } else if (e.getStatusCode() == -1) {
            // no connection
            response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
        } else {
            // general error
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        }
    }
}

From source file:br.shura.team.mpsbot.venusext.Retweet.java

License:Open Source License

@Override
public void callVoid(Context context, FunctionCallDescriptor descriptor) throws ScriptRuntimeException {
    ConnectedBot bot = context.getApplicationContext().getUserData("bot", ConnectedBot.class);
    Twitter twitter = bot.getHandler();
    IntegerValue value = (IntegerValue) descriptor.get(0);

    Helper.execute(context, () -> twitter.retweetStatus(value.value()));
}

From source file:com.daiv.android.twitter.ui.tweet_viewer.fragments.TweetFragment.java

License:Apache License

public void retweetStatus(final TextView retweetCount, final long tweetId, final View retweetButton,
        final int type) {
    Toast.makeText(context, getResources().getString(R.string.retweeting_status), Toast.LENGTH_SHORT).show();

    new Thread(new Runnable() {
        @Override/*from   ww  w  . ja v a 2s .  c o  m*/
        public void run() {
            try {

                // if they have a protected account, we want to still be able to retweet their retweets
                long idToRetweet = tweetId;
                if (status != null && status.isRetweet()) {
                    idToRetweet = status.getRetweetedStatus().getId();
                }

                Twitter twitter = null;
                Twitter secTwitter = null;
                if (type == TYPE_ACC_ONE) {
                    twitter = Utils.getTwitter(context, settings);
                } else if (type == TYPE_ACC_TWO) {
                    secTwitter = Utils.getSecondTwitter(context);
                } else {
                    twitter = Utils.getTwitter(context, settings);
                    secTwitter = Utils.getSecondTwitter(context);
                }

                if (twitter != null) {
                    try {
                        twitter.retweetStatus(idToRetweet);
                    } catch (TwitterException e) {

                    }
                }

                if (secTwitter != null) {
                    try {
                        secTwitter.retweetStatus(idToRetweet);
                    } catch (TwitterException e) {

                    }
                }

                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            Toast.makeText(context, getResources().getString(R.string.retweet_success),
                                    Toast.LENGTH_SHORT).show();
                            getRetweetCount(retweetCount, tweetId, retweetButton);
                        } catch (Exception e) {

                        }
                    }
                });
            } catch (Exception e) {

            }
        }
    }).start();
}

From source file:com.klinker.android.twitter.ui.tweet_viewer.fragments.TweetFragment.java

License:Apache License

public void retweetStatus(final TextView retweetCount, final long tweetId, final View retweetButton) {
    Toast.makeText(context, getResources().getString(R.string.retweeting_status), Toast.LENGTH_SHORT).show();

    new Thread(new Runnable() {
        @Override/*from   w w w.j  a v a  2 s. com*/
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);
                twitter.retweetStatus(tweetId);

                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            Toast.makeText(context, getResources().getString(R.string.retweet_success),
                                    Toast.LENGTH_SHORT).show();
                            getRetweetCount(retweetCount, tweetId, retweetButton);
                        } catch (Exception e) {

                        }
                    }
                });
            } catch (Exception e) {

            }
        }
    }).start();
}

From source file:com.twitstreet.twitter.AnnouncerMgrImpl.java

License:Open Source License

@Override
public void retweet(long statusId) {
    Twitter twitter = random();
    String screenName = "";
    try {/*  w w w  . j a v a 2 s.  co m*/
        twitter.retweetStatus(statusId);
        screenName = twitter.getScreenName();
    } catch (TwitterException e) {
        logger.error("Error while retweeting: " + statusId + " Announcer: " + screenName, e);
    }
}

From source file:com.twitstreet.twitter.AnnouncerMgrImpl.java

License:Open Source License

@Override
public void retweetForDiabloBird(long statusId) {
    Twitter twitter = diablobird;
    String screenName = "";
    try {//from w w w. j a  v  a2  s . com
        twitter.retweetStatus(statusId);
        screenName = twitter.getScreenName();
        logger.info("retweetForDiabloBird");
    } catch (TwitterException e) {
        logger.error("Error while retweeting: " + statusId + " Announcer: " + screenName, e);
    }
}

From source file:de.dev.eth0.retweeter.Retweeter.java

License:BEER-WARE LICENSE

/**
 * Performs the retweet-action and returns the number of tweets found with the configured hashtag
 *
 * @return number of retweeted tweets/*from   ww w .j av a2s . com*/
 * @throws TwitterException
 */
public int retweet() throws TwitterException {
    if (!getConfig().isRetweeterConfigValid()) {
        return Integer.MIN_VALUE;
    }
    Twitter twitter = getTwitter();
    String search = buildSearchString();
    Query query = new Query(search);
    QueryResult result = twitter.search(query);

    List<Status> lastretweets = twitter.getRetweetedByMe();
    int count = 0;
    for (Tweet tweet : result.getTweets()) {
        // ignore retweets and check if the hashtag is really in the tweet's text
        if (!StringUtils.startsWith(tweet.getText(), "RT @")
                && StringUtils.contains(tweet.getText(), getConfig().getRetweeterConfig().getHashtag())
                && !ALREADY_RETWEETED.contains(tweet.getId())) {
            boolean retweeted = false;
            for (Status retweet : lastretweets) {
                if (tweet.getId() == retweet.getRetweetedStatus().getId()) {
                    retweeted = true;
                    break;
                }
            }
            if (!retweeted) {
                // try to retweet, might fail
                logger.debug("found new tweet to retweet: {}", tweet.toString());
                try {
                    twitter.retweetStatus(tweet.getId());
                    count++;
                } catch (TwitterException te) {
                    logger.debug("retweet failed", te);
                } finally {
                    ALREADY_RETWEETED.add(tweet.getId());
                }
            }
        }
    }
    return count;
}

From source file:it.greenvulcano.gvesb.social.twitter.directcall.TwitterOperationRetweetStatus.java

License:Open Source License

@Override
public void execute(SocialAdapterAccount account) throws SocialAdapterException {
    try {/*from ww w  . j av  a2 s.c om*/
        Twitter twitter = (Twitter) account.getProxyObject();
        status = twitter.retweetStatus(Long.parseLong(statusId));
    } catch (NumberFormatException exc) {
        logger.error("Call to TwitterOperationRetweetStatus failed. Check statusId format.", exc);
        throw new SocialAdapterException("Call to TwitterOperationRetweetStatus failed. Check statusId format.",
                exc);
    } catch (TwitterException exc) {
        logger.error("Call to TwitterOperationRetweetStatus failed.", exc);
        throw new SocialAdapterException("Call to TwitterOperationRetweetStatus failed.", exc);
    }
}

From source file:org.examproject.tweet.service.SimpleTweetService.java

License:Apache License

private Status retweetStatus(long statusId) {
    Status status = null;//w ww . ja  v a  2s .  c  o  m
    try {
        Twitter twitter = getTwitter();
        status = twitter.retweetStatus(statusId);
    } catch (TwitterException te) {
        LOG.error("an error occurred: " + te.getMessage());
        throw new RuntimeException(te);
    }
    return status;
}

From source file:org.timur.justin.JustInActivity.java

License:Apache License

@Override
public Dialog onCreateDialog(final int id) {
    Dialog menuDialog = null;//from w  w  w  .jav a2  s. c o  m

    if (id == DIALOG_ABOUT) {
        if (Config.LOGD)
            Log.i(LOGTAG, "onCreateDialog id==DIALOG_ABOUT setContentView(R.layout.about_dialog)");
        menuDialog = new Dialog(this, R.style.NoTitleDialog);
        menuDialog.setContentView(R.layout.about_dialog);

        PackageInfo pinfo;
        int versionNumber = 0;
        String versionName = "";
        try {
            pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
            versionNumber = pinfo.versionCode;
            versionName = pinfo.versionName;
            if (Config.LOGD)
                Log.i(LOGTAG, "onCreateDialog id==DIALOG_ABOUT manifest versionName=" + versionName);
            TextView textView = (TextView) menuDialog.findViewById(R.id.aboutVersion);
            textView.setText((CharSequence) ("v" + versionName), TextView.BufferType.NORMAL);
        } catch (android.content.pm.PackageManager.NameNotFoundException nnfex) {
            Log.e(LOGTAG, "onClick btnAbout FAILED on getPackageManager().getPackageInfo(getPackageName(), 0) "
                    + nnfex);
        }

        return menuDialog;
    }

    final GradientDrawable mBackgroundGradient = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
            new int[] { 0x30606060, 0x30000000 });

    if (currentEntryTopic != null) {
        if (Config.LOGD)
            Log.i(LOGTAG, "onCreateDialog() id=" + id + " link=" + currentEntryTopic.link);
    }
    menuDialog = new Dialog(this, R.style.NoTitleDialog);

    if (id == DIALOG_USE_MSG) {
        menuDialog.setContentView(R.layout.open_dialog);
        menuDialog.findViewById(R.id.buttonLayout).setBackgroundDrawable(mBackgroundGradient);

        // tweet
        Button btnTweetReply = (Button) menuDialog.findViewById(R.id.buttonOpenTweetReply);
        if (btnTweetReply != null) {
            btnTweetReply.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "onClick btnTweetReply");
                    if (currentEntryTopic != null) {
                        if (serviceClientObject != null) {
                            TickerServiceAbstract tickerService = serviceClientObject.getServiceObject();
                            TwitterServiceAbstract twitterService = (TwitterServiceAbstract) tickerService;
                            if (twitterService != null) {
                                final Twitter twitter = twitterService.getTwitterObject();
                                if (twitter != null) {
                                    final EditText editText = new EditText(context);
                                    int maxLength = 140;
                                    InputFilter[] FilterArray = new InputFilter[1];
                                    FilterArray[0] = new InputFilter.LengthFilter(maxLength);
                                    editText.setFilters(FilterArray);
                                    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            switch (which) {
                                            case DialogInterface.BUTTON_POSITIVE:
                                                String inputText = editText.getText().toString();
                                                try {
                                                    twitter.updateStatus(inputText);
                                                } catch (twitter4j.TwitterException twex) {
                                                    Log.e(LOGTAG, "FAILED on twitter.updateStatus() " + twex);
                                                    Toast.makeText(context, twex.getMessage(),
                                                            Toast.LENGTH_LONG).show();
                                                }
                                                break;
                                            case DialogInterface.BUTTON_NEGATIVE:
                                                break;
                                            }
                                        }
                                    };
                                    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
                                    alertDialogBuilder.setTitle("Reply tweet");
                                    alertDialogBuilder.setMessage(ripTags(currentEntryTopic.title));
                                    editText.setText(
                                            "@" + currentEntryTopic.shortName + " "
                                                    + ripTags(currentEntryTopic.title),
                                            TextView.BufferType.EDITABLE);
                                    // todo: should show length of message (or rather: 140 - number of characters)
                                    alertDialogBuilder.setView(editText);
                                    alertDialogBuilder.setPositiveButton("Send", dialogClickListener)
                                            .setNegativeButton("Abort", dialogClickListener).show();
                                }
                            }
                        }
                    }
                    dismissDialog(id);
                }
            });
        }

        // retweet
        Button btnRetweet = (Button) menuDialog.findViewById(R.id.buttonOpenRetweet);
        if (btnRetweet != null) {
            btnRetweet.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "onClick btnRetweet");
                    if (currentEntryTopic != null) {
                        if (serviceClientObject != null) {
                            TickerServiceAbstract tickerService = serviceClientObject.getServiceObject();
                            TwitterServiceAbstract twitterService = (TwitterServiceAbstract) tickerService;
                            if (twitterService != null) {
                                final Twitter twitter = twitterService.getTwitterObject();
                                if (twitter != null) {
                                    // yes/no dialog
                                    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            switch (which) {
                                            case DialogInterface.BUTTON_POSITIVE:
                                                try {
                                                    twitter.retweetStatus(currentEntryTopic.id);
                                                    Toast.makeText(context, "delivered retweet",
                                                            Toast.LENGTH_SHORT).show();
                                                } catch (twitter4j.TwitterException twex) {
                                                    Log.e(LOGTAG, "FAILED on twitter.retweetStatus() " + twex);
                                                    Toast.makeText(context, twex.getMessage(),
                                                            Toast.LENGTH_LONG).show();
                                                }
                                                break;
                                            case DialogInterface.BUTTON_NEGATIVE:
                                                break;
                                            }
                                        }
                                    };
                                    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
                                    alertDialogBuilder.setTitle("Retweet");
                                    alertDialogBuilder.setMessage(ripTags(currentEntryTopic.title));
                                    alertDialogBuilder.setPositiveButton("Send", dialogClickListener)
                                            .setNegativeButton("Abort", dialogClickListener).show();
                                }
                            }
                        }
                    }
                    dismissDialog(id);
                }
            });
        }

        // mark as Favorit
        Button btnMarkFavorit = (Button) menuDialog.findViewById(R.id.buttonMarkFavorit);
        if (btnMarkFavorit != null) {
            btnMarkFavorit.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "onClick btnMarkFavorit");
                    if (currentEntryTopic != null) {
                        if (serviceClientObject != null) {
                            if (Config.LOGD)
                                Log.i(LOGTAG, "onClick btnMarkFavorit get tickerService...");
                            TickerServiceAbstract tickerService = serviceClientObject.getServiceObject();
                            TwitterServiceAbstract twitterService = (TwitterServiceAbstract) tickerService;
                            if (twitterService != null) {
                                if (Config.LOGD)
                                    Log.i(LOGTAG, "onClick btnMarkFavorit got twitterService");
                                final Twitter twitter = twitterService.getTwitterObject();
                                if (twitter != null) {
                                    if (Config.LOGD)
                                        Log.i(LOGTAG, "onClick btnMarkFavorit got twitterObject");
                                    // yes/no dialog
                                    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            switch (which) {
                                            case DialogInterface.BUTTON_POSITIVE:
                                                try {
                                                    twitter.createFavorite(currentEntryTopic.id);
                                                } catch (twitter4j.TwitterException twex) {
                                                    Log.e(LOGTAG, "FAILED on twitter.retweetStatus() " + twex);
                                                    Toast.makeText(context, twex.getMessage(),
                                                            Toast.LENGTH_LONG).show();
                                                }
                                                break;
                                            case DialogInterface.BUTTON_NEGATIVE:
                                                break;
                                            }
                                        }
                                    };
                                    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
                                    if (Config.LOGD)
                                        Log.i(LOGTAG, "onClick btnMarkFavorit got alertDialogBuilder");
                                    alertDialogBuilder.setTitle("Mark as favorit");
                                    alertDialogBuilder.setMessage(ripTags(currentEntryTopic.title));
                                    if (Config.LOGD)
                                        Log.i(LOGTAG, "onClick btnMarkFavorit alertDialogBuilder start...");
                                    alertDialogBuilder.setPositiveButton("Favorit", dialogClickListener)
                                            .setNegativeButton("Abort", dialogClickListener).show();
                                    if (Config.LOGD)
                                        Log.i(LOGTAG, "onClick btnMarkFavorit alertDialogBuilder started");
                                }
                            }
                        }
                    }
                    dismissDialog(id);
                }
            });
        }

        // Browse...
        Button btnBrowse = (Button) menuDialog.findViewById(R.id.buttonOpenBrowse);
        if (btnBrowse != null) {
            btnBrowse.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "btnBrowse currentEntryTopic=" + currentEntryTopic);
                    if (currentEntryTopic != null) {
                        glView.openCurrentMsgInBrowser(currentEntryTopic);
                    }
                    dismissDialog(id);
                }
            });
        }

        // Send by Mail
        Button btnEmail = (Button) menuDialog.findViewById(R.id.buttonOpenEmail);
        if (btnEmail != null) {
            btnEmail.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "btnEmail currentEntryTopic=" + currentEntryTopic);
                    if (currentEntryTopic != null && currentEntryTopic.title != null) {
                        Intent sendMailIntent = new Intent(Intent.ACTION_SEND);
                        sendMailIntent.putExtra(Intent.EXTRA_SUBJECT, currentEntryTopic.channelName + ": "
                                + ripTags(currentEntryTopic.title).substring(0, 40) + "...");
                        sendMailIntent.putExtra(Intent.EXTRA_TEXT, ripTags(currentEntryTopic.title));
                        sendMailIntent.setType("message/rfc822");
                        startActivity(sendMailIntent);
                    }
                    dismissDialog(id);
                }
            });
        }

        // Send by SMS
        Button btnSMS = (Button) menuDialog.findViewById(R.id.buttonOpenSMS);
        if (btnSMS != null) {
            btnSMS.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "btnSMS currentEntryTopic=" + currentEntryTopic);
                    if (currentEntryTopic != null) {
                        Uri smsUri = Uri.parse("smsto:");
                        Intent sendSmsIntent = new Intent(Intent.ACTION_SENDTO, smsUri);
                        sendSmsIntent.putExtra("sms_body",
                                currentEntryTopic.channelName + ": " + ripTags(currentEntryTopic.title));
                        //sendSmsIntent.setType("vnd.android-dir/mms-sms");
                        try {
                            startActivity(sendSmsIntent);
                        } catch (Exception ex) {
                            String errMsg = ex.getMessage();
                            Toast.makeText(context, errMsg, Toast.LENGTH_LONG).show();
                        }
                    }
                    dismissDialog(id);
                }
            });
        }

        //      // bluetooth
        //      Button btnBluetooth = (Button)menuDialog.findViewById(R.id.buttonOpenBluetooth);
        //      if(btnBluetooth!=null) {
        //        btnBluetooth.setOnClickListener(new View.OnClickListener() {
        //            public void onClick(View view) { 
        //              if(currentEntryTopic!=null) {
        //                // todo: must implement
        //                Toast.makeText(context, "bluetooth not yet implemented", Toast.LENGTH_LONG).show();
        //              }
        //              dismissDialog(id);
        //            } 
        //          }
        //        );
        //      }

        // close
        Button btnClose = (Button) menuDialog.findViewById(R.id.buttonClose);
        if (btnClose != null) {
            btnClose.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    dismissDialog(id);
                }
            });
        }

    } else if (id == DIALOG_MORE) {
        menuDialog.setContentView(R.layout.more_dialog);
        menuDialog.findViewById(R.id.buttonLayout).setBackgroundDrawable(mBackgroundGradient);

        // browse Favorits
        Button btnBrowseFavorits = (Button) menuDialog.findViewById(R.id.buttonBrowseFavorits);
        if (btnBrowseFavorits != null) {
            btnBrowseFavorits.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "onClick btnBrowseFavorits glView=" + glView);
                    if (glView != null) {
                        if (serviceClientObject != null) {
                            TickerServiceAbstract tickerService = serviceClientObject.getServiceObject();
                            TwitterServiceAbstract twitterService = (TwitterServiceAbstract) tickerService;
                            if (Config.LOGD)
                                Log.i(LOGTAG, "onClick btnBrowseFavorits twitterService=" + twitterService);
                            if (twitterService != null) {
                                final Twitter twitter = twitterService.getTwitterObject();
                                if (twitter != null) {
                                    try {
                                        glView.openInBrowser(
                                                "http://twitter.com/" + twitter.getScreenName() + "/favorites");
                                    } catch (twitter4j.TwitterException twex) {
                                        Log.e(LOGTAG, "FAILED on twitter.getScreenName() " + twex);
                                        Toast.makeText(context, twex.getMessage(), Toast.LENGTH_LONG).show();
                                    }
                                }
                            }
                        }
                    }
                    dismissDialog(id);
                }
            });
        }

        // re-login / clear password
        Button btnClearPassword = (Button) menuDialog.findViewById(R.id.buttonClearPassword);
        if (btnClearPassword != null) {
            btnClearPassword.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "onClick btnClearPassword serviceClientObject=" + serviceClientObject);
                    if (serviceClientObject != null) {
                        final TickerServiceAbstract tickerService = serviceClientObject.getServiceObject();
                        final TwitterServiceAbstract twitterService = (TwitterServiceAbstract) tickerService;
                        if (Config.LOGD)
                            Log.i(LOGTAG, "onClick btnClearPassword twitterService=" + twitterService);
                        if (twitterService != null) {

                            // yes/no dialog
                            DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    switch (which) {
                                    case DialogInterface.BUTTON_POSITIVE:
                                        if (Config.LOGD)
                                            Log.i(LOGTAG, "onClick btnClearPassword MENU_CLEAR_PASSWORD");
                                        twitterService.clearTwitterLogin();
                                        // restart activity
                                        if (Config.LOGD)
                                            Log.i(LOGTAG, "onClick btnClearPassword restart activity");
                                        Intent intent = getIntent();
                                        overridePendingTransition(0, 0);
                                        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                                        finish();
                                        try {
                                            Thread.sleep(1500);
                                        } catch (Exception ex2) {
                                        }
                                        ;
                                        if (Config.LOGD)
                                            Log.i(LOGTAG,
                                                    "onClick btnClearPassword finish() done, starting...");
                                        overridePendingTransition(0, 0);
                                        startActivity(intent);
                                        // on restart, OAuthActivity will be opened
                                        break;
                                    case DialogInterface.BUTTON_NEGATIVE:
                                        break;
                                    }
                                }
                            };
                            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
                            if (Config.LOGD)
                                Log.i(LOGTAG, "onClick btnClearPassword got alertDialogBuilder");
                            alertDialogBuilder.setTitle("Re-Login");
                            if (Config.LOGD)
                                Log.i(LOGTAG, "onClick btnClearPassword alertDialogBuilder start...");
                            alertDialogBuilder.setPositiveButton("Re-Login", dialogClickListener)
                                    .setNegativeButton("Abort", dialogClickListener).show();
                            if (Config.LOGD)
                                Log.i(LOGTAG, "onClick btnClearPassword alertDialogBuilder started");
                        }
                    }

                    dismissDialog(id);
                }
            });
        }

        // shutdown all
        Button btnShutdownAll = (Button) menuDialog.findViewById(R.id.buttonShutdownAll);
        if (btnShutdownAll != null) {
            btnShutdownAll.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "onClick btnShutdownAll serviceClientObject=" + serviceClientObject);

                    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            switch (which) {
                            case DialogInterface.BUTTON_POSITIVE:
                                if (serviceClientObject != null) {
                                    TickerServiceAbstract tickerService = serviceClientObject
                                            .getServiceObject();
                                    if (tickerService != null) {
                                        if (Config.LOGD)
                                            Log.i(LOGTAG, "onClick btnShutdownAll tickerService.stopSelf()");
                                        tickerService.stopSelf();
                                    }
                                }
                                if (Config.LOGD)
                                    Log.i(LOGTAG, "onClick btnShutdownAll System.exit(0)");
                                System.exit(0);
                                break;
                            case DialogInterface.BUTTON_NEGATIVE:
                                break;
                            }
                        }
                    };
                    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
                    alertDialogBuilder.setTitle("Shutdown all");
                    alertDialogBuilder.setPositiveButton("Shut down", dialogClickListener)
                            .setNegativeButton("Keep running", dialogClickListener).show();
                    dismissDialog(id);
                }
            });
        }

        // about
        Button btnAbout = (Button) menuDialog.findViewById(R.id.buttonAbout);
        if (btnAbout != null) {
            btnAbout.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "onClick btnAbout");
                    showDialog(DIALOG_ABOUT);
                    dismissDialog(id);
                }
            });
        }

        // promote
        Button btnPromote = (Button) menuDialog.findViewById(R.id.buttonPromote);
        if (btnPromote != null) {
            btnPromote.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "onClick btnPromote");
                    showDialog(DIALOG_PROMOTE);
                    dismissDialog(id);
                }
            });
        }

        // close
        Button btnClose = (Button) menuDialog.findViewById(R.id.buttonClose);
        if (btnClose != null) {
            btnClose.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    dismissDialog(id);
                }
            });
        }
    } else if (id == DIALOG_PROMOTE) {
        if (Config.LOGD)
            Log.i(LOGTAG, "onCreateDialog id==DIALOG_PROMOTE setContentView(R.layout.promote_dialog)");
        menuDialog = new Dialog(this, R.style.NoTitleDialog);
        menuDialog.setContentView(R.layout.promote_dialog);

        // promote mail
        Button btnPromoteMail = (Button) menuDialog.findViewById(R.id.buttonPromoteMail);
        if (btnPromoteMail != null) {
            btnPromoteMail.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "onClick btnPromoteMail");

                    Intent sendMailIntent = new Intent(Intent.ACTION_SEND);
                    sendMailIntent.putExtra(Intent.EXTRA_SUBJECT, "Just in... for Android");
                    sendMailIntent.putExtra(Intent.EXTRA_TEXT,
                            "Hi \ncheck this out...\n\nJust in... OpenGL Twitter reader free download from Android Market\nhttp://market.android.com/details?id=org.timur.justin\n");
                    sendMailIntent.setType("message/rfc822");
                    startActivity(sendMailIntent);

                    dismissDialog(id);
                }
            });
        }

        // promote SMS
        Button btnPromoteSMS = (Button) menuDialog.findViewById(R.id.buttonPromoteSMS);
        if (btnPromoteSMS != null) {
            btnPromoteSMS.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "onClick btnPromoteSMS");

                    Uri smsUri = Uri.parse("smsto:");
                    Intent sendSmsIntent = new Intent(Intent.ACTION_SENDTO, smsUri);
                    sendSmsIntent.putExtra("sms_body",
                            "Just in... OpenGL Twitter reader free DL from Android Market http://market.android.com/details?id=org.timur.justin");
                    //sendSmsIntent.setType("vnd.android-dir/mms-sms");
                    try {
                        startActivity(sendSmsIntent);
                    } catch (Exception ex) {
                        String errMsg = ex.getMessage();
                        Toast.makeText(context, errMsg, Toast.LENGTH_LONG).show();
                    }

                    dismissDialog(id);
                }
            });
        }

        // promote tweet
        Button btnPromoteTweet = (Button) menuDialog.findViewById(R.id.buttonPromoteTweet);
        if (btnPromoteTweet != null) {
            btnPromoteTweet.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    if (Config.LOGD)
                        Log.i(LOGTAG, "onClick btnPromoteTweet");

                    if (serviceClientObject != null) {
                        TickerServiceAbstract tickerService = serviceClientObject.getServiceObject();
                        TwitterServiceAbstract twitterService = (TwitterServiceAbstract) tickerService;
                        if (twitterService != null) {
                            final Twitter twitter = twitterService.getTwitterObject();
                            if (twitter != null) {
                                final EditText editText = new EditText(context);
                                int maxLength = 140;
                                InputFilter[] FilterArray = new InputFilter[1];
                                FilterArray[0] = new InputFilter.LengthFilter(maxLength);
                                editText.setFilters(FilterArray);
                                DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        switch (which) {
                                        case DialogInterface.BUTTON_POSITIVE:
                                            String inputText = editText.getText().toString();
                                            try {
                                                twitter.updateStatus(inputText);
                                            } catch (twitter4j.TwitterException twex) {
                                                Log.e(LOGTAG, "FAILED on twitter.updateStatus() " + twex);
                                                Toast.makeText(context, twex.getMessage(), Toast.LENGTH_LONG)
                                                        .show();
                                            }
                                            break;
                                        case DialogInterface.BUTTON_NEGATIVE:
                                            break;
                                        }
                                    }
                                };
                                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
                                alertDialogBuilder.setTitle("Tweet");
                                //alertDialogBuilder.setMessage("");
                                editText.setText(
                                        "'Just in...' #OpenGL #Twitter reader free DL from #Android Market http://market.android.com/details?id=org.timur.justin",
                                        TextView.BufferType.EDITABLE);
                                // todo: should show length of message (or rather: 140 - number of characters)
                                alertDialogBuilder.setView(editText);
                                alertDialogBuilder.setPositiveButton("Send", dialogClickListener)
                                        .setNegativeButton("Abort", dialogClickListener).show();
                            }
                        }
                    }

                    dismissDialog(id);
                }
            });
        }
    }

    return menuDialog;
}