title: How To Post Image on twitter using post URL using Android?
body: <p>I have tried twitter4j-core-2.1.11.jar using this jar, posting image was fine. but now i  have used apache-mime4j-0.6.jar ,httpmime-4.0.1.jar, scribe-1.3.3.jar. <code>Login and posting tweet as text its working</code> . but i <code>want to post image with text message</code> how can i post it ...
  <code>i dont want to use twitter4j-core-2.1.11.jar</code>
  i want to use <code>https://api.twitter.com/1.1/statuses/update_with_media.json</code>. Please Tell ME how to post Image.. </p>
  
  <p>See my code bellow.</p>
  
  <pre><code>      public class MainActivity extends Activity {
  
  // TWITTER SHARE VARIABLES
  final static String APIKEY = "***********";
  final static String APISECRET = "*******************************";
  final static String CALLBACK = "http://www.google.com";
  OAuthService Oathserv;
  Token requestToken;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
       StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
          StrictMode.setThreadPolicy(policy);
      findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              if (isInternetAvailable()) {
                  postStatusOnTwitter();
              } else {
                  Toast.makeText(getApplicationContext(),
                          "Internet service not available", Toast.LENGTH_LONG)
                          .show();
              }
          }
      });
  }
  
  public boolean isInternetAvailable() {
      ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
      if (cm.getActiveNetworkInfo() != null)
          return (cm.getActiveNetworkInfo().isConnected() &amp;&amp; cm
                  .getActiveNetworkInfo().isAvailable());
      else
          return false;
  }
  
  // TWITTER SHARING START
  private void postStatusOnTwitter() {
  
      final WebView webView1 = (WebView) findViewById(R.id.webView1);
      webView1.setVisibility(View.VISIBLE);
      webView1.requestFocus(View.FOCUS_DOWN);
      webView1.setOnTouchListener(new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
              switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
              case MotionEvent.ACTION_UP:
                  if (!v.hasFocus()) {
                      v.requestFocus();
                  }
                  break;
              }
              return false;
          }
      });
  
      // set up service and get request token as seen on scribe website
      // https://github.com/fernandezpablo85/scribe-java/wiki/Getting-Started
  
      // attach WebViewClient to intercept the callback url
      webView1.setWebViewClient(new WebViewClient() {
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
  
              // check for our custom callback protocol otherwise use
              // default
              // behavior
              if (url.startsWith("http")) {
                  // authorization complete hide webview for now.
                  webView1.setVisibility(View.GONE);
  
                  Uri uri = Uri.parse(url);
                  String verifier = uri.getQueryParameter("oauth_verifier");
  
                  if (verifier != null) {
                      Verifier v = new Verifier(verifier);
  
                      // save this token for practical use.
                      Token accessToken = Oathserv.getAccessToken(requestToken, v);
  
  
  
  
  
  
  
  
                      // host twitter detected from callback
                      // oauth://twitter
                      Log.e("Host", uri.getHost().toString());
                      if (uri.getHost().equals("www.google.com")) {
                          /*
                           * OAuthRequest req = new OAuthRequest(Verb.GET,
                           * "http://api.twitter.com/1/account/verify_credentials.json"
                           * );
                           */
                      /*  OAuthRequest req = new OAuthRequest(Verb.POST,
                                  "https://api.twitter.com/1.1/statuses/update.json");
  
                          req.addBodyParameter("status", "Hello Twitter");
  
                          Oathserv.signRequest(accessToken, req);
                          */
  
                          OAuthRequest req = new OAuthRequest(Verb.POST,
                                  "https://api.twitter.com/1.1/statuses/update_with_media.json");
  
                         //   req.addBodyParameter("status", "bdf Twitter");
                          req.addBodyParameter("media[]", "http://i.stack.imgur.com/wz0qZ.jpg"); // here will be image 
  
                          Oathserv.signRequest(accessToken, req);
  
  
  
  
                          org.scribe.model.Response response = req.send();
  
  
  
  
  
  
  
  
  
  
                          try {
                              JSONObject json = new JSONObject(response
                                      .getBody());
                              android.util.Log.i("Twitter Response",
                                      json.toString());
                              Toast.makeText(getApplicationContext(),
                                      "Shared on twitter successfully",
                                      Toast.LENGTH_LONG).show();
                          } catch (JSONException e) {
                              e.printStackTrace();
                          }
  
  
  
  
                      }
                  }
  
                  return true;
              }
  
              return super.shouldOverrideUrlLoading(view, url);
          }
      });
  
      new Handler().post(new Runnable() {
  
          @Override
          public void run() {
              // TODO Auto-generated method stub
              try {
                  Oathserv = new ServiceBuilder().provider(TwitterApi.class)
                          .apiKey(APIKEY).apiSecret(APISECRET)
                          .callback(CALLBACK).build();
  
                  requestToken = Oathserv.getRequestToken();
                  final String authURL = Oathserv.getAuthorizationUrl(requestToken);
                  // send user to authorization page
                  webView1.loadUrl(authURL);
              } catch (Exception e) {
                  // TODO: handle exception
                  e.printStackTrace();
              }
          }
      });
  }
  
  // TWITTER SHARING END
  
          }
  </code></pre>