Java – Android Facebook dialog

Android Facebook dialog… here is a solution to the problem.

Android Facebook dialog

I have integrated Facebook into my app. However, instead of displaying in a dialog box, it opens in full screen. I wonder if anyone knows how to change it to a conversation.

Facebook handler class:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

/*
     * Get existing access_token if any
     */      
    mPrefs = getPreferences(MODE_PRIVATE);
    String access_token = mPrefs.getString("access_token", null);
    long expires = mPrefs.getLong("access_expires", 0);

if(access_token != null) 
        facebook.setAccessToken(access_token);

if(expires != 0) 
        facebook.setAccessExpires(expires);

if (facebook.isSessionValid()) 
      postFacebookMessage();

else {
      facebook.authorize(this, new String[] {"publish_stream"}, new Facebook.DialogListener() {

@Override
        public void onFacebookError(FacebookError e) {
            Toast.makeText(FacebookConnector.this, "Facebook error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        }

@Override
        public void onError(DialogError e) {
            Toast.makeText(FacebookConnector.this, "Facebook dialog error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        }

@Override
        public void onComplete(Bundle values) {
                postFacebookMessage();
            Toast.makeText(FacebookConnector.this, "Thank You For Sharing!", Toast.LENGTH_SHORT).show(); }

@Override
        public void onCancel() {Toast.makeText(FacebookConnector.this, "Facebook authorization cancelled.", Toast.LENGTH_LONG).show();
        }
    });
    }
} 

private void postFacebookMessage() {

AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
  Bundle params = new Bundle();
  params.putString("message", MSG);
  params.putString("picture", "http://meanwhileinwv.com/meanwhile.png");
  mAsyncRunner.request("me/feed", params, "POST", new FacebookPostListener(), null); }    

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    facebook.authorizeCallback(requestCode, resultCode, data);
}
}

The above code produces the following result:

enter image description here

I want it to be the dialog box that the facebook window opens. I’ve implemented this with my Twitter code:

enter image description here

Solution

Invoke authorization with additional parameter Facebook.FORCE_DIALOG_AUTH as follows:

facebook.authorize(this, new String[] {"publish_stream"}, Facebook.FORCE_DIALOG_AUTH, new Facebook.DialogListener() { ... });

Related Problems and Solutions

Java – Android Facebook dialog

Android Facebook dialog… here is a solution to the problem.

Android Facebook dialog

I have integrated Facebook into my app. However, instead of displaying in a dialog box, it opens in full screen. I wonder if anyone knows how to change it to a conversation.

Facebook handler class:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

/*
     * Get existing access_token if any
     */      
    mPrefs = getPreferences(MODE_PRIVATE);
    String access_token = mPrefs.getString("access_token", null);
    long expires = mPrefs.getLong("access_expires", 0);

if(access_token != null) 
        facebook.setAccessToken(access_token);

if(expires != 0) 
        facebook.setAccessExpires(expires);

if (facebook.isSessionValid()) 
      postFacebookMessage();

else {
      facebook.authorize(this, new String[] {"publish_stream"}, new Facebook.DialogListener() {

@Override
        public void onFacebookError(FacebookError e) {
            Toast.makeText(FacebookConnector.this, "Facebook error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        }

@Override
        public void onError(DialogError e) {
            Toast.makeText(FacebookConnector.this, "Facebook dialog error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        }

@Override
        public void onComplete(Bundle values) {
                postFacebookMessage();
            Toast.makeText(FacebookConnector.this, "Thank You For Sharing!", Toast.LENGTH_SHORT).show(); }

@Override
        public void onCancel() {Toast.makeText(FacebookConnector.this, "Facebook authorization cancelled.", Toast.LENGTH_LONG).show();
        }
    });
    }
} 

private void postFacebookMessage() {

AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
  Bundle params = new Bundle();
  params.putString("message", MSG);
  params.putString("picture", "http://meanwhileinwv.com/meanwhile.png");
  mAsyncRunner.request("me/feed", params, "POST", new FacebookPostListener(), null); }    

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    facebook.authorizeCallback(requestCode, resultCode, data);
}
}

The above code produces the following result:

enter image description here

I want it to be the dialog box that the facebook window opens. I’ve implemented this with my Twitter code:

enter image description here

Solution

Invoke authorization with additional parameter Facebook.FORCE_DIALOG_AUTH as follows:

facebook.authorize(this, new String[] {"publish_stream"}, Facebook.FORCE_DIALOG_AUTH, new Facebook.DialogListener() { ... });

Related Problems and Solutions

Java – Android Facebook dialog

Android Facebook dialog… here is a solution to the problem.

Android Facebook dialog

I have integrated Facebook into my app. However, instead of displaying in a dialog box, it opens in full screen. I wonder if anyone knows how to change it to a conversation.

Facebook handler class:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

/*
     * Get existing access_token if any
     */      
    mPrefs = getPreferences(MODE_PRIVATE);
    String access_token = mPrefs.getString("access_token", null);
    long expires = mPrefs.getLong("access_expires", 0);

if(access_token != null) 
        facebook.setAccessToken(access_token);

if(expires != 0) 
        facebook.setAccessExpires(expires);

if (facebook.isSessionValid()) 
      postFacebookMessage();

else {
      facebook.authorize(this, new String[] {"publish_stream"}, new Facebook.DialogListener() {

@Override
        public void onFacebookError(FacebookError e) {
            Toast.makeText(FacebookConnector.this, "Facebook error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        }

@Override
        public void onError(DialogError e) {
            Toast.makeText(FacebookConnector.this, "Facebook dialog error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        }

@Override
        public void onComplete(Bundle values) {
                postFacebookMessage();
            Toast.makeText(FacebookConnector.this, "Thank You For Sharing!", Toast.LENGTH_SHORT).show(); }

@Override
        public void onCancel() {Toast.makeText(FacebookConnector.this, "Facebook authorization cancelled.", Toast.LENGTH_LONG).show();
        }
    });
    }
} 

private void postFacebookMessage() {

AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
  Bundle params = new Bundle();
  params.putString("message", MSG);
  params.putString("picture", "http://meanwhileinwv.com/meanwhile.png");
  mAsyncRunner.request("me/feed", params, "POST", new FacebookPostListener(), null); }    

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    facebook.authorizeCallback(requestCode, resultCode, data);
}
}

The above code produces the following result:

enter image description here

I want it to be the dialog box that the facebook window opens. I’ve implemented this with my Twitter code:

enter image description here

Solution

Invoke authorization with additional parameter Facebook.FORCE_DIALOG_AUTH as follows:

facebook.authorize(this, new String[] {"publish_stream"}, Facebook.FORCE_DIALOG_AUTH, new Facebook.DialogListener() { ... });

Related Problems and Solutions

Java – Android Facebook dialog

Android Facebook dialog… here is a solution to the problem.

Android Facebook dialog

I have integrated Facebook into my app. However, instead of displaying in a dialog box, it opens in full screen. I wonder if anyone knows how to change it to a conversation.

Facebook handler class:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

/*
     * Get existing access_token if any
     */      
    mPrefs = getPreferences(MODE_PRIVATE);
    String access_token = mPrefs.getString("access_token", null);
    long expires = mPrefs.getLong("access_expires", 0);

if(access_token != null) 
        facebook.setAccessToken(access_token);

if(expires != 0) 
        facebook.setAccessExpires(expires);

if (facebook.isSessionValid()) 
      postFacebookMessage();

else {
      facebook.authorize(this, new String[] {"publish_stream"}, new Facebook.DialogListener() {

@Override
        public void onFacebookError(FacebookError e) {
            Toast.makeText(FacebookConnector.this, "Facebook error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        }

@Override
        public void onError(DialogError e) {
            Toast.makeText(FacebookConnector.this, "Facebook dialog error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        }

@Override
        public void onComplete(Bundle values) {
                postFacebookMessage();
            Toast.makeText(FacebookConnector.this, "Thank You For Sharing!", Toast.LENGTH_SHORT).show(); }

@Override
        public void onCancel() {Toast.makeText(FacebookConnector.this, "Facebook authorization cancelled.", Toast.LENGTH_LONG).show();
        }
    });
    }
} 

private void postFacebookMessage() {

AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
  Bundle params = new Bundle();
  params.putString("message", MSG);
  params.putString("picture", "http://meanwhileinwv.com/meanwhile.png");
  mAsyncRunner.request("me/feed", params, "POST", new FacebookPostListener(), null); }    

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    facebook.authorizeCallback(requestCode, resultCode, data);
}
}

The above code produces the following result:

enter image description here

I want it to be the dialog box that the facebook window opens. I’ve implemented this with my Twitter code:

enter image description here

Solution

Invoke authorization with additional parameter Facebook.FORCE_DIALOG_AUTH as follows:

facebook.authorize(this, new String[] {"publish_stream"}, Facebook.FORCE_DIALOG_AUTH, new Facebook.DialogListener() { ... });

Related Problems and Solutions

Java – Android Facebook dialog

Android Facebook dialog… here is a solution to the problem.

Android Facebook dialog

I have integrated Facebook into my app. However, instead of displaying in a dialog box, it opens in full screen. I wonder if anyone knows how to change it to a conversation.

Facebook handler class:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

/*
     * Get existing access_token if any
     */      
    mPrefs = getPreferences(MODE_PRIVATE);
    String access_token = mPrefs.getString("access_token", null);
    long expires = mPrefs.getLong("access_expires", 0);

if(access_token != null) 
        facebook.setAccessToken(access_token);

if(expires != 0) 
        facebook.setAccessExpires(expires);

if (facebook.isSessionValid()) 
      postFacebookMessage();

else {
      facebook.authorize(this, new String[] {"publish_stream"}, new Facebook.DialogListener() {

@Override
        public void onFacebookError(FacebookError e) {
            Toast.makeText(FacebookConnector.this, "Facebook error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        }

@Override
        public void onError(DialogError e) {
            Toast.makeText(FacebookConnector.this, "Facebook dialog error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        }

@Override
        public void onComplete(Bundle values) {
                postFacebookMessage();
            Toast.makeText(FacebookConnector.this, "Thank You For Sharing!", Toast.LENGTH_SHORT).show(); }

@Override
        public void onCancel() {Toast.makeText(FacebookConnector.this, "Facebook authorization cancelled.", Toast.LENGTH_LONG).show();
        }
    });
    }
} 

private void postFacebookMessage() {

AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
  Bundle params = new Bundle();
  params.putString("message", MSG);
  params.putString("picture", "http://meanwhileinwv.com/meanwhile.png");
  mAsyncRunner.request("me/feed", params, "POST", new FacebookPostListener(), null); }    

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    facebook.authorizeCallback(requestCode, resultCode, data);
}
}

The above code produces the following result:

enter image description here

I want it to be the dialog box that the facebook window opens. I’ve implemented this with my Twitter code:

enter image description here

Solution

Invoke authorization with additional parameter Facebook.FORCE_DIALOG_AUTH as follows:

facebook.authorize(this, new String[] {"publish_stream"}, Facebook.FORCE_DIALOG_AUTH, new Facebook.DialogListener() { ... });

Related Problems and Solutions