Sunday, May 29, 2011

[android-developers] post on wall

I have the following code that posts a message on a facebook wall:


package com.greatapp;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.facebook.android.*;
import com.facebook.android.Facebook.*;

public class hmm extends Activity {
static Context c;
Facebook facebook = new Facebook("app id");

@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
c = this.getApplicationContext();
setContentView(R.layout.main);

String[] permissions = new String[] { "publish_stream",
"read_stream",
"offline_access"

};
facebook.authorize(this, permissions,

new DialogListener() {
@Override
public void onComplete(Bundle values) {
postOnWall("this is a test");

}

@Override
public void onFacebookError(FacebookError error) {
}

@Override
public void onError(DialogError e) {
}

@Override
public void onCancel() {
}
});

}

public void postOnWall(String msg) {

try {
String response = facebook.request("me");
Bundle parameters = new Bundle();
parameters.putString("message", msg);
parameters.putString("description", "test test test");
response = facebook.request("me/feed", parameters, "POST");

if (response == null || response.equals("")
|| response.equals("false")) {

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

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

facebook.authorizeCallback(requestCode, resultCode, data);
}
}

It works on one phone but seems to exit quickly on another. Any ideas
why it fails on one phone?


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate