Eu ja estou utilização a ultima versao do sdk..
2012/12/26 Paulo Borges <pauloborgesfilho@gmail.com>
Você está usando o SDK antigo do Facebook.Dê uma olhada aqui: https://developers.facebook.com/android/E nesse link explica o passo a passo inicial: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/--
On Wed, Dec 26, 2012 at 2:04 PM, Bruna Borges <brunamanke@gmail.com> wrote:o codigo q faz a interligação com o facebook eh essa--public class ShareActivity extends Activity {public Facebook facebook = new Facebook("435603643172246");private AsyncFacebookRunner mAsyncRunner;public Toast fbToast = null;public static boolean CLEAR_SESSIONS = false;SharedPreferences prefs;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.share);Matrix matrix = new Matrix();//matrix.postRotate(357);ImageView image = (ImageView) findViewById( R.id.photocanvas );Bitmap photo = BitmapFactory.decodeFile( "/sdcard/photoCanvas.jpg" );Bitmap canvasImg = Bitmap.createBitmap(1024, 600, Bitmap.Config.ARGB_8888);Canvas canvas = new Canvas(canvasImg);Paint mShadow = new Paint();mShadow.setShadowLayer(10.0f, 2.0f, 2.0f, 0xFF000000);canvas.drawBitmap(photo, matrix, mShadow);image.setImageBitmap(canvasImg);Button facebookBtn = (Button) findViewById(R.id.facebookBtn);facebookBtn.setOnClickListener(facebookListener);fbToast = Toast.makeText(getApplicationContext(), "...", Toast.LENGTH_SHORT);mAsyncRunner = new AsyncFacebookRunner(facebook);if( CLEAR_SESSIONS ){try {facebook.logout( getApplicationContext() );} catch (MalformedURLException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}prefs = PreferenceManager.getDefaultSharedPreferences(this);}private OnClickListener facebookListener = new OnClickListener() {public void onClick(View v) {facebook.authorize(ShareActivity.this, new String[] { "user_photos","publish_actions", "publish_stream","photo_upload", "manage_pages" }, new Facebook.DialogListener() {public void onComplete(Bundle values) {String access_token = "AAAGMLeBqBZAYBANnOcV5KX1c0gmGH9Sak9VUsskQ2MzqrNTTz6N7TZAG9BsjL1hPHmK5PXZA2ulSjZBEHL1gAHzxUCKZAGRMZCdM0bE42574hKyKFejJxE";/*try {String response = facebook.request("me/accounts");Log.d("RESPONSE", response);} catch (MalformedURLException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}*/Bundle params = new Bundle();//params.putString("method", "photos.upload");Bitmap photoCanvas = Shrinkmethod("/sdcard/photoCanvas.jpg", 1024, 600);ByteArrayOutputStream bos = new ByteArrayOutputStream();photoCanvas.compress(CompressFormat.JPEG, 70 /*ignored for PNG*/, bos);byte[] imgData = bos.toByteArray();params.putByteArray("picture", imgData);facebook.setAccessToken(access_token);mAsyncRunner.request("435603643172246/photos?access_token="+access_token, params, "POST",new FacebookUploadListener(), null);fbToast.setText("Enviando");fbToast.show();}public Bitmap Shrinkmethod(String file,int width,int height){BitmapFactory.Options bitopt=new BitmapFactory.Options();bitopt.inJustDecodeBounds=true;Bitmap bit=BitmapFactory.decodeFile(file, bitopt);int h=(int) Math.ceil(bitopt.outHeight/(float)height);int w=(int) Math.ceil(bitopt.outWidth/(float)width);if(h>1 || w>1){if(h>w){bitopt.inSampleSize=h;}else{bitopt.inSampleSize=w;}}bitopt.inJustDecodeBounds=false;bit=BitmapFactory.decodeFile(file, bitopt);
return bit;}public void onFacebookError(FacebookError error) {}public void onError(DialogError e) {}public void onCancel() {}});}};public class FacebookUploadListener implements RequestListener {public void onComplete(String response, Object state) {fbToast.setText("Foto enviada com sucesso");fbToast.show();Intent i = new Intent(ShareActivity.this, AgradecimentoActivity.class);ShareActivity.this.startActivity(i);}public void onIOException(IOException e, Object state) {fbToast.setText("Erro ao enviar, tente novamente");fbToast.show();}public void onFileNotFoundException(FileNotFoundException e,Object state) {fbToast.setText("Erro ao enviar, tente novamente");fbToast.show();}public void onMalformedURLException(MalformedURLException e,Object state) {fbToast.setText("Erro ao enviar, tente novamente");fbToast.show();}public void onFacebookError(FacebookError e, Object state) {fbToast.setText("Erro ao enviar, tente novamente");fbToast.show();}}}mas ele chama o facebook mas la fala q da um erro
Em quarta-feira, 26 de dezembro de 2012 14h41min54s UTC-2, Bruna Borges escreveu:Tenho uma duvida criar um aplicativo com o facebook,gerar a senha registrei no facebook mas na hora de compartilhar da um erro..Alguem poderia me ajudar na configuração do facebook e como o facebook vai se comunicar com o meu app...
--
0 comentários:
Postar um comentário