views:

65

answers:

0
package org.androidpeople.facebook;

import net.xeomax.FBRocket.FBRocket;
import net.xeomax.FBRocket.Facebook;
import net.xeomax.FBRocket.LoginListener;
import net.xeomax.FBRocket.ServerErrorException;
import android.app.Activity;
import android.os.Bundle;

public class FacebookRocketExample extends Activity implements LoginListener {

 private FBRocket fbRocket;

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  shareFacebook();
 }

 public void shareFacebook() {
  fbRocket = new FBRocket(this, "SPC Project","00b0a669821ecbb4a646f822fdb56ffe");

  if (fbRocket.existsSavedFacebook()) {
   fbRocket.loadFacebook();
  } else {
   fbRocket.login(R.layout.main);
  }
 }

 @Override
 public void onLoginFail() {
  fbRocket.displayToast("Login failed!");
  fbRocket.login(R.layout.main);
 }

 @Override
 public void onLoginSuccess(Facebook facebook) {
  // TODO Auto-generated method stub
  fbRocket.displayToast("Login success!");

  try {
   facebook.setStatus("Now Begin with  ");
   fbRocket.displayDialog("Status Posted Successfully!! "
     + facebook.getStatus());
  } catch (ServerErrorException e) {
   if (e.notLoggedIn()) {
    fbRocket.login(R.layout.main);
   } else {
    System.out.println(e);
   }
  }
 }



}