una texto que puedo publicación publicaciones publicacion mis imagen hecha google fotos example editar cómo compartir como cambiar borrarla agregar afecte android facebook android-intent

que - Android: ¿Cómo compartir imágenes con texto en Facebook a través de la intención?



¿cómo cambiar la imagen de un post en facebook? (7)

A partir de 2017, Facebook no permite compartir una imagen + texto juntos, directamente desde su aplicación.

Solución

Facebook, sin embargo, raspará una URL para los datos de título e imagen y la usará en una publicación compartida.

Como solución, puede crear una aplicación de una sola página * que cargue dinámicamente el texto / imagen que desea compartir (especificado en la URL) y usted puede compartir esa URL en Facebook.

Notas:

  • Asegúrese de que su aplicación de una sola página produzca una página estática que tenga su título, abra metaetiquetas de gráficos e imágenes establecidas antes del raspado de la página de Facebook. Si estas etiquetas de la página web se cambian dinámicamente a través de Javascript, Facebook no podrá raspar esos valores y usarlos en su publicación compartida.
  • Utilice las etiquetas de propiedad de metagráficas abiertas og: image: height y og: image: width para permitir que facebook cree una vista previa de la imagen dentro de su publicación compartida

Pasos

0) agregue la última biblioteca de facebook-sdk a su archivo build.gradle

compile group: ''com.facebook.android'', name: ''facebook-android-sdk'', version: ''4.25.0''

1) En su AndroidManifest.xml, agregue una etiqueta de metadatos dentro de su sección <application> :

<application android:label="@string/app_name" ...> ... <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/> ... </application>

Agregue una cadena facebook_app_id (con su ID de aplicación) a su archivo strings.xml:

<string name="facebook_app_id">12341234</string>

YOURFBAPPID es su número de identificación de aplicación de Facebook que se encuentra en https://developers.facebook.com/apps/

2) también agregue una etiqueta <provider> fuera de su etiqueta <application> en AndroidManifest.xml

<provider android:authorities="com.facebook.app.FacebookContentProviderYOURFBAPPID" android:name="com.facebook.FacebookContentProvider" android:exported="true"/>

3) Crea un objeto ShareLinkContent usando su constructor:

ShareLinkContent fbShare = new ShareLinkContent.Builder() .setContentUrl(Uri.parse("http://yourdomain.com/your-title-here/someimagefilename")) .build();

4) Compártalo desde tu fragmento (o actividad, etc.):

ShareDialog.show(getActivity(), fbShare);

Documentos de Facebook

https://developers.facebook.com/docs/android/getting-started

Me gustaría compartir una foto con subtítulos precargados de mi aplicación a través de un intento de compartir, en Facebook.

Código de ejemplo

Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_TEXT, "eample"); intent.putExtra(Intent.EXTRA_TITLE, "example"); intent.putExtra(Intent.EXTRA_SUBJECT, "example"); intent.putExtra(Intent.EXTRA_STREAM, imageUri); Intent openInChooser = new Intent(intent); openInChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents); startActivity(openInChooser);

Aquí está la captura de pantalla lo que recibo

Si un tipo de ajuste para image / * se carga una foto sin el texto prellenado. Si se establece en texto / foto simple, no se visualiza .....


Agregue estas líneas a su siguiente código

shareCaptionIntent.putExtra(Intent.EXTRA_TITLE, "my awesome caption in the EXTRA_TITLE field");


FB ya no le permite precompletar el mensaje de intercambio.

Para evitar esto, deberá usar un SDK para publicar a través de una solicitud de gráfico. Para esto, necesitará el permiso publish_actions . Desde el mes pasado, debe enviar su aplicación a un proceso de revisión para obtener acceso a publish_actions . Lo cual fallaría si su aplicación llena previamente los textos compartidos. Créeme, he tenido el Chutzppah para probar.

Entonces parece que tendríamos que cumplir.

Por cierto, en iOS puedes rellenar los textos con el SDK de FB. Quién sabe por cuánto tiempo.


Las versiones más recientes de Facebook no le permiten compartir texto con intenciones. Tienes que usar el SDK de Facebook para hacerlo: para hacerlo simple, usa el Facebook SDK + Android Simple Facebook ( https://github.com/sromku/android-simple-facebook ). Usando la biblioteca, tu código sería así (extraído del sitio simple de Facebook):

Publicar feed

Establezca OnPublishListener y llame para:

  • publish(Feed, OnPublishListener) sin diálogo.
  • publish(Feed, true, OnPublishListener) con diálogo.

Propiedades básicas

  • message - El mensaje del usuario
  • name : el nombre del enlace adjunto
  • caption : la leyenda del enlace (aparece debajo del nombre del enlace)
  • description - La descripción del enlace (aparece debajo del título del enlace)
  • picture : la URL de una imagen adjunta a esta publicación. La imagen debe ser de al menos 200px por 200px
  • link - El enlace adjunto a esta publicación

Inicializar escucha de devolución de llamada:

OnPublishListener onPublishListener = new OnPublishListener() { @Override public void onComplete(String postId) { Log.i(TAG, "Published successfully. The new post id = " + postId); } /* * You can override other methods here: * onThinking(), onFail(String reason), onException(Throwable throwable) */ };

Generar feed

Feed feed = new Feed.Builder() .setMessage("Clone it out...") .setName("Simple Facebook for Android") .setCaption("Code less, do the same.") .setDescription("The Simple Facebook library project makes the life much easier by coding less code for being able to login, publish feeds and open graph stories, invite friends and more.") .setPicture("https://raw.github.com/sromku/android-simple-facebook/master/Refs/android_facebook_sdk_logo.png") .setLink("https://github.com/sromku/android-simple-facebook") .build();

Publicar feed sin diálogo:

mSimpleFacebook.publish(feed, onPublishListener);

Publicar feed con el diálogo:

mSimpleFacebook.publish(feed, true, onPublishListener);


Actualización el 14 de diciembre de 2015


de acuerdo con el nuevo SDK de Facebook.

facebook-android-sdk: 4.6.0

Es muy sencillo.
1. crear proveedor en Android.manifest.xml

<provider android:authorities="com.facebook.app.FacebookContentProvider{APP_ID}" android:name="com.facebook.FacebookContentProvider" android:exported="true" />

2. Cree su intención de compartir con los datos.

ShareLinkContent shareLinkContent = new ShareLinkContent.Builder() .setContentTitle("Your Title") .setContentDescription("Your Description") .setContentUrl(Uri.parse("URL[will open website or app]")) .setImageUrl(Uri.parse("image or logo [if playstore or app store url then no need of this image url]")) .build();


3. Mostrar el cuadro de diálogo Compartir

ShareDialog.show(ShowNavigationActivity.this,shareLinkContent);


Eso es.


Prueba con esto

private void initShareIntent(String type,String _text){ File filePath = getFileStreamPath("shareimage.jpg"); //optional //internal storage Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, _text); shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(filePath))); //optional//use this when you want to send an image shareIntent.setType("image/jpeg"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(Intent.createChooser(shareIntent, "send")); }


Sin utilizar Facebook SDK no podemos compartir la imagen y el texto simultáneamente en Facebook. Para resolver este problema, tuve que crear un mapa de bits de imagen y texto, compartir ese mapa de bits en Facebook y está funcionando perfectamente.

Puede descargar el código fuente desde aquí ( Compartir imagen y texto en Facebook con intención en Android )

Aquí está el código:

MainActivity.java

package com.shareimage; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; import android.view.View; import android.widget.EditText; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class MainActivity extends AppCompatActivity implements View.OnClickListener { EditText et_text; ImageView iv_image; TextView tv_share,tv_text; RelativeLayout rl_main; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); init(); } private void init(){ et_text = (EditText)findViewById(R.id.et_text); iv_image = (ImageView)findViewById(R.id.iv_image); tv_share = (TextView)findViewById(R.id.tv_share); rl_main = (RelativeLayout)findViewById(R.id.rl_main); tv_text= (TextView) findViewById(R.id.tv_text); File dir = new File("/sdcard/Testing/"); try { if (dir.mkdir()) { System.out.println("Directory created"); } else { System.out.println("Directory is not created"); } } catch (Exception e) { e.printStackTrace(); } tv_share.setOnClickListener(this); et_text.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { tv_text.setText(et_text.getText().toString()); } }); } @Override public void onClick(View v) { switch (v.getId()){ case R.id.tv_share: Bitmap bitmap1 = loadBitmapFromView(rl_main, rl_main.getWidth(), rl_main.getHeight()); saveBitmap(bitmap1); String str_screenshot = "/sdcard/Testing/"+"testing" + ".jpg"; fn_share(str_screenshot); break; } } public void saveBitmap(Bitmap bitmap) { File imagePath = new File("/sdcard/Testing/"+"testing" + ".jpg"); FileOutputStream fos; try { fos = new FileOutputStream(imagePath); bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos); fos.flush(); fos.close(); Log.e("ImageSave", "Saveimage"); } catch (FileNotFoundException e) { Log.e("GREC", e.getMessage(), e); } catch (IOException e) { Log.e("GREC", e.getMessage(), e); } } public static Bitmap loadBitmapFromView(View v, int width, int height) { Bitmap b = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); v.draw(c); return b; } public void fn_share(String path) { File file = new File("/mnt/" + path); Bitmap bmp = BitmapFactory.decodeFile(file.getAbsolutePath()); Uri uri = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_STREAM, uri); startActivity(Intent.createChooser(intent, "Share Image")); } }


Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("image/*"); shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, (String) v.getTag(R.string.app_name)); shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri); // put your image URI PackageManager pm = v.getContext().getPackageManager(); List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0); for (final ResolveInfo app : activityList) { if ((app.activityInfo.name).contains("facebook")) { final ActivityInfo activity = app.activityInfo; final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name); shareIntent.addCategory(Intent.CATEGORY_LAUNCHER); shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); shareIntent.setComponent(name); v.getContext().startActivity(shareIntent); break; } }