title: Share via facebook/twitter application in android , don't open browser if facebook/twitter is installed on the device
body: <p>As the title implies , I would like to share something via facebook/twitter in android .If the facebook/twitter is installed , I want to share the post via the fb/twitter application , otherwise I want to direct to the user to the browser . I can direct the user to the browser it is easy , but how can I share post via the fb/twitter application ? </p>
  
  <p>Thanks..</p>
  
  <p>(Editted)
  I've tried to do this , examined developers.facebook.com , however they're doing this operation via fragments. I want to do it with default activity . I've tried the code below however I'm getting error like </p>
  
  <pre><code>W/dalvikvm(16093): VFY: unable to find class referenced in signature     (Landroid/support/v4/app/Fragment;)
  W/dalvikvm(16093): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
  W/dalvikvm(16093): VFY: unable to resolve static method 367: Landroid/support/v4/content/LocalBroadcastManager;.getInstance (Landroid/content/Context;)Landroid/support/v4/content/LocalBroadcastManager;
  </code></pre>
  
  <p>The code I used in the default activity is :</p>
  
  <pre><code>private void publishStory() {
          Session currentSession = Session.getActiveSession();
  
  
          if (currentSession != null){
  
  
              Bundle postParams = new Bundle();
              postParams.putString("name", Commons.campaignname);
              postParams.putString("display", "touch");
              postParams.putString("link",  Commons.campaignlink");
              postParams.putString("picture",Commons.campaignimage);
  
              Request.Callback callback= new Request.Callback() {
                  public void onCompleted(Response response) {
                      JSONObject graphResponse = response
                                                 .getGraphObject()
                                                 .getInnerJSONObject();
                      String postId = null;
                      try {
                          postId = graphResponse.getString("id");
                      } catch (JSONException e) {
                          Log.i("TAG",
                              "JSON error "+ e.getMessage());
                      }
                      FacebookRequestError error = response.getError();
                      if (error != null) {
                          Toast.makeText(getApplicationContext(),
                               error.getErrorMessage(),
                               Toast.LENGTH_SHORT).show();
                          } else {
                              Toast.makeText(getApplicationContext(), 
                                   postId,
                                   Toast.LENGTH_LONG).show();
                      }
                  }
              };
  
              Request request = new Request(currentSession, "me/feed", postParams, 
                                    HttpMethod.POST, callback);
  
              RequestAsyncTask task = new RequestAsyncTask(request);
              task.execute();
          }
  
      }
  
      private boolean isSubsetOf(Collection&lt;String&gt; subset, Collection&lt;String&gt; superset) {
          for (String string : subset) {
              if (!superset.contains(string)) {
                  return false;
              }
          }
          return true;
  
  }
  </code></pre>