Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook integration in android application [closed]

Is there any api for facebook to integration in android?

I got a requirement to publish images to facebook through android application.

Please give links or suggestions regarding this..

like image 712
manidhar mulaparthi Avatar asked Jul 30 '10 13:07

manidhar mulaparthi


2 Answers

If you had taken the time to Google "Android Facebook SDK" you'd have immediately found the official Android Facebook SDK: http://github.com/facebook/facebook-android-sdk

Having used it in a project I can say it's a little rough around the edges as the new oAuth / Graph API based stuff is quite young, but it works well with a little tweaking.

like image 149
Yoni Samlan Avatar answered Oct 04 '22 11:10

Yoni Samlan


import java.awt.BorderLayout;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

import com.sun.medialib.mlib.Image;

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.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Handler.Callback;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

public class TestRocket extends Activity implements LoginListener {

public FBRocket fbRocket;



public static String currentFileName ;



public final String images[] = {"http://safesport.site40.net/tv.jpg"};


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

    shareFacebook();


}



public void shareFacebook() {
    fbRocket = new FBRocket(this, "test",
    "ommited");

    if (fbRocket.existsSavedFacebook()) {
        fbRocket.loadFacebook();
        return;
    } else {
        //fbRocket.login(R.layout.testrocket);
        fbRocket.login(R.layout.testrocket);

    }
}


public void onLoginFail() {
    fbRocket.displayToast("Login failed!");
    //fbRocket.login(R.layout.correr);
}
public String setFileName(String filename) {
    // TODO Auto-generated method stub
    TestRocket.currentFileName = filename;

    return filename;
}

public void onLoginSuccess(Facebook facebook) {

    SimpleDateFormat sdf = new SimpleDateFormat("dd:MM:yyyy");
    SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm:ss");
    String data = sdf.format(new Date());
    String time = sdf1.format(new Date());

    try {



        facebook.setStatus("Start Walk:"+time+"\n"+ "Day:"+data+"\n"+"Where:"+"\n"
                +"http://maps.google.com/?q=http://safesport.site40.net/"+currentFileName);
        fbRocket.displayToast("Status Posted Successfully!! ");
        return ;
    } catch (ServerErrorException e) {
        if (e.notLoggedIn()) {
            fbRocket.login(R.layout.ciclismo);


        } else {
            System.out.println(e);
        }

    }


}
}
like image 27
Pragna Avatar answered Oct 04 '22 11:10

Pragna