Question: I ma developing one application in i have to share data and image to Twitter from my android Application.I am following <http://chintankhetiya.wordpress.com/2013/07/18/sharing-text-image-in-twitter-android-example/comment-page-1/#comment-285> this.I did change consumer key and consumer secret .While Running my App one Toast message coming Login Faild .Please tell me any thing required for this

Answer: 
For twitter sharing you can share file directly from the twitter app if it is install and if the app is not install you can use twitter api. 

Below is the code for both the things

```
Boolean isTwitterAppAvailable =false;
try {

            Intent shareIntent = new Intent(
                    android.content.Intent.ACTION_SEND);

            shareIntent.setType("image/*");
            shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                    "Content to share");

            PackageManager pm = getPackageManager();
            List<ResolveInfo> activityList = pm.queryIntentActivities(
                    shareIntent, 0);
            for (final ResolveInfo app : activityList) {
                if (app.activityInfo.name.contains("twitter")) {

                    final ActivityInfo activity = app.activityInfo;
                    final ComponentName name = new ComponentName(
                            activity.applicationInfo.packageName,
                            activity.name);
                    shareIntent.setClassName("com.twitter.android",
                            "com.twitter.android.PostActivity");

                    shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                    shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                            | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
                    shareIntent.setComponent(name);

                    shareIntent.putExtra(Intent.EXTRA_TEXT,
                            GlobalApplication.twitter_share_msg);

                    if (GlobalApplication.isImageShareTwitter)
                        shareIntent.putExtra(Intent.EXTRA_STREAM,
                                Uri.parse("file:///sdcard/attachment.jpg"));
                    isTwitterAppAvailable = true;

                    startActivity(shareIntent);

                    break;
                }
            }

            if (!isTwitterAppAvailable) {

                if (isNetworkAvailable()) {

                    GlobalApplication.casted_image = casted_image;

                    // twitter web sharing using twitter4j api...

                    Twitt_Sharing twitt = new Twitt_Sharing(
                            ShowCampaignDetail.this, twitter_consumer_key,
                            twitter_secret_key);

                    twitt.shareToTwitter(
                            GlobalApplication.twitter_share_msg,
                            casted_image);

                    Twitter_Handler tHandler = new Twitter_Handler(
                            ShowCampaignDetail.this, twitter_consumer_key,
                            twitter_secret_key);
                    User user;
                    try {
                        user = tHandler.twitterObj
                                .showUser(tHandler.twitterObj.getId());
                        String url = user.getProfileImageURL();
                    } catch (IllegalStateException e) { // TODO
                                                        // Auto-generated
                        e.printStackTrace();
                    } catch (TwitterException e) {
                        e.printStackTrace();
                    }

                } else {
                    Toast.makeText(ShowCampaignDetail.this,
                            "No Network Connection Available !!!",
                            Toast.LENGTH_LONG).show();
                }

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

```
```
Use Following code :

/*
 * Share any Image.
 */
private void shareImage() {
    Intent share = new Intent(Intent.ACTION_SEND);
    // If you want to share a png image only, you can do:
    // setType("image/png"); OR for jpeg: setType("image/jpeg");
    share.setType("image/*");
    // Make sure you put example png image named myImage.png in your
    // directory
    String imagePath = Environment.getExternalStorageDirectory()
            + "/myImage.png";
    File imageFileToShare = new File(imagePath);
    Uri uri = Uri.fromFile(imageFileToShare);
    share.putExtra(Intent.EXTRA_STREAM, uri);
    startActivity(Intent.createChooser(share, "Share image to..."));
}

```