title: Android Facebook Login : How to check login using LoginManager without having LoginButton in XML
body: <p>I have done facebook login check in my android app using LoginButton, but I want to check using LoginManager. How can I modify my code to work that way?</p>
  
  <pre><code>   LoginButton loginButton = (LoginButton) findViewById(R.id.fb_login_button);
      loginButton.setReadPermissions("user_friends");
  
      shareDialog = new ShareDialog(this);
  
      //Login Callback registration
      LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback&lt;LoginResult&gt;() {
          @Override
          public void onSuccess(LoginResult loginResult) {
              Toast.makeText(getApplicationContext(), "in LoginResult on success", Toast.LENGTH_LONG).show();
  
              //Login success - process to Post
              if (ShareDialog.canShow(ShareLinkContent.class)) {
                  String description = "description";
                  ShareLinkContent linkContent = new ShareLinkContent.Builder()
                          .setContentTitle("title")
                          .setContentDescription(description)
                          .setContentUrl(Uri.parse("http://google.com"))
                          .setImageUrl(Uri.parse("http://google.com"))
                          .build();
  
                  shareDialog.show(linkContent, ShareDialog.Mode.FEED);
              }
  
          }
  
          @Override
          public void onCancel() {
              Toast.makeText(getApplicationContext(), "in LoginResult on cancel", Toast.LENGTH_LONG).show();
          }
  
          @Override
          public void onError(FacebookException exception) {
              Toast.makeText(getApplicationContext(), "in LoginResult on error", Toast.LENGTH_LONG).show();
          }
      });
  </code></pre>
  
  <p>Also I want to open Facebook login dialog if user is not logged in before opening by Share dialog. The Login dialog should be same as Share Dialog (in a popup). How to do it?</p>
  
  <p>Thanks! </p>