I am trying to create a small app that posts the entries made by an user in my app to facebook when they press the back button to quit. I already have SSO and everything else set up, the problem is it does not recognize PostDialogListener as a valid listener. Says does not exist, the code where I am trying to use it
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
Log.d(this.getClass().getName(), "back button pressed");
fb.dialog(getApplicationContext(), "stream.publish", new PostDialogListener());
Toast t=Toast.makeText(getApplicationContext(), " Back pressed ", Toast.LENGTH_LONG);
t.show();
}
return super.onKeyDown(keyCode, event);
}
I tried putting the dialog code in other places too, but same result, PostDialogListener is not being recognized.
You probably don't import it from example. Add these classes to your project:
public abstract class BaseDialogListener implements DialogListener {
@Override
public void onFacebookError(FacebookError e) {
e.printStackTrace();
}
@Override
public void onError(DialogError e) {
e.printStackTrace();
}
@Override
public void onCancel() {
}
}
public class PostDialogListener extends BaseDialogListener {
@Override
public void onComplete(Bundle values) {
final String postId = values.getString("post_id");
if (postId != null) {
showToast("Message posted on the wall.");
} else {
showToast("No message posted on the wall.");
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.