I have an app where I want to share a history in facebook. I don't have a web for my application. I only want to share an image with title and description and if it's posible that when click on the shared site they redirect to google play to download app or to facebook app page.
I look for an answer in most of facebook samples and here and there is something that I'm doing wrong for sure.
I made all the facebook app configuration. Key hashes, etc... I create a history in open graph called Publicar a Lugar. Action="Publicar" Object="Lugar".
I've this code
private void OpenShareDialog(){
Session session = Session.getActiveSession();
if (session != null) {
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
}
OpenGraphObject oplugar = OpenGraphObject.Factory.createForPost("namespace:lugar");
oplugar.setProperty("og:type","namespace:lugar");
oplugar.setProperty("og:title", LugarCargado.getNombre());
//oplugar.setProperty("og:image", "http://estaticos.sport.es/resources/jpg/2/1/1391546433412.jpg");
//oplugar.setProperty("og:url", "http://www.udg.edu/");
oplugar.setProperty("og:description", LugarCargado.getDescripcion());
//Bitmap bitmap;
//List<Bitmap> bitmaps = new ArrayList<Bitmap>();
//bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.icoappfacebook2);
//Log.i(TAG, "Imagen: Height:"+bitmap.getHeight()+ " Width:"+ bitmap.getWidth());
//bitmaps.add(bitmap);
//OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
OpenGraphAction action = OpenGraphAction.Factory.createForPost("namespace:publicar");
action.setProperty("lugar", oplugar);
action.setType("namespace:publicar");
action.setProperty("previewPropertyName", oplugar);
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(this, action, "lugar")
//.setImageAttachmentsForObject("lugar", bitmaps, true)
//.setImageAttachmentsForAction(bitmaps,true);
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
I have two diferent errors debugging in my smartphone:
1- if I uncomment one of this lines
//oplugar.setProperty("og:image", "http://estaticos.sport.es/resources/jpg/2/1/1391546433412.jpg");
//oplugar.setProperty("og:url", "http://www.udg.edu/");
I have an error that says "com.facebook.FacebookException: Failed to generate preview for user.". I can't putt an url
2- If I want to add a custom image. If I uncomment this code
//Bitmap bitmap;
//List<Bitmap> bitmaps = new ArrayList<Bitmap>();
//bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.icoappfacebook2);
//Log.i(TAG, "Imagen: Height:"+bitmap.getHeight()+ " Width:"+ bitmap.getWidth());
//bitmaps.add(bitmap);
and
//.setImageAttachmentsForAction(bitmaps,true);
I have a black window and something seems to be restarted...
02-08 15:09:46.500: W/GAV3(15911): Thread[GAThread,5,main]: Service unavailable (code=1),
will retry.
02-08 15:09:46.500: I/GAV3(15911): Thread[GAThread,5,main]: No
campaign data found. 02-08 15:09:48.482: D/AbsListView(15911):
unregisterIRListener() is called 02-08 15:09:48.982:
D/AbsListView(15911): onVisibilityChanged() is called, visibility : 4
02-08 15:09:48.982: D/AbsListView(15911): unregisterIRListener() is
called 02-08 15:09:51.525: W/GAV3(15911): Thread[Service
Reconnect,5,main]: Service unavailable (code=1), using local store.
02-08 15:09:53.778: D/AbsListView(16092): Get MotionRecognitionManager
02-08 15:09:53.778: D/AbsListView(16092): onVisibilityChanged() is
called, visibility : 8 02-08 15:09:53.778: D/AbsListView(16092):
unregisterIRListener() is called 02-08 15:09:53.788:
D/ProgressBar(16092): setProgress = 0 02-08 15:09:53.788:
D/ProgressBar(16092): setProgress = 0, fromUser = false 02-08
15:09:53.788: D/ProgressBar(16092): mProgress = 0mIndeterminate =
false, mMin = 0, mMax = 10000 02-08 15:09:53.828:
D/AbsListView(16092): onVisibilityChanged() is called, visibility : 4
02-08 15:09:53.828: D/AbsListView(16092): unregisterIRListener() is
called 02-08 15:09:53.838: D/AbsListView(16092):
onVisibilityChanged() is called, visibility : 0 02-08 15:09:53.838:
D/AbsListView(16092): unregisterIRListener() is called 02-08
15:09:53.848: D/libEGL(16092): loaded
/system/lib/egl/libEGL_adreno200.so 02-08 15:09:53.858:
D/libEGL(16092): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
02-08 15:09:53.858: D/libEGL(16092): loaded
/system/lib/egl/libGLESv2_adreno200.so 02-08 15:09:53.858:
I/Adreno200-EGL(16092): : EGL 1.4
QUALCOMM build:
AYELDER_AU_LINUX_ANDROID_JB_2.5.5.04.02.02.092.023+PATCH[ES]_msm8960_JB_2.5.5_CL3556704_release_ENGG (CL3556704) 02-08 15:09:53.858: I/Adreno200-EGL(16092): Build Date:
05/17/13 Fri 02-08 15:09:53.858: I/Adreno200-EGL(16092): Local Branch:
02-08 15:09:53.858: I/Adreno200-EGL(16092): Remote Branch:
quic/jb_2.5.5 02-08 15:09:53.858: I/Adreno200-EGL(16092): Local
Patches: 34c9e193f12610d3e68dabd6198d2c4bfbc66974 RB: Update the
master
timestamp of the hw_image in rb_texture_update_aliased 02-08
15:09:53.858: I/Adreno200-EGL(16092): Reconstruct Branch:
AU_LINUX_ANDROID_JB_2.5.5.04.02.02.092.023 + 01d3c78 +
e6f0547 + LOCAL_PATCH[ES] 02-08 15:09:53.878:
D/OpenGLRenderer(16092): Enabling debug mode 0 02-08 15:09:53.878:
D/ProgressBar(16092): updateDrawableBounds: left = 0 02-08
15:09:53.878: D/ProgressBar(16092): updateDrawableBounds: top = 0
02-08 15:09:53.878: D/ProgressBar(16092): updateDrawableBounds: right
= 72 02-08 15:09:53.878: D/ProgressBar(16092): updateDrawableBounds: bottom = 72 02-08 15:09:54.058: I/System(16092): Loaded time zone
names for en in 217ms (205ms in ICU) 02-08 15:09:54.088:
D/AbsListView(16092): onVisibilityChanged() is called, visibility : 0
02-08 15:09:54.088: D/AbsListView(16092): unregisterIRListener() is
called 02-08 15:09:54.168: D/AbsListView(16092):
unregisterIRListener() is called 02-08 15:09:54.178:
D/AbsListView(16092): unregisterIRListener() is called 02-08
15:09:54.188: E/ViewRootImpl(16092): sendUserActionEvent() mView ==
null 02-08 15:09:54.268: D/AbsListView(16092): unregisterIRListener()
is called 02-08 15:09:58.833: W/GAV3(16092): Thread[GAThread,5,main]:
Service unavailable (code=1), will retry. 02-08 15:09:58.833:
I/GAV3(16092): Thread[GAThread,5,main]: No campaign data found. 02-08
15:10:03.838: W/GAV3(16092): Thread[Service Reconnect,5,main]: Service
unavailable (code=1), using local store. 02-08 15:10:10.565:
D/AbsListView(16092): unregisterIRListener() is called
and display the previous activity.
With the above code sharedialog shows me the facebook dialog and I can share. But without link and without my image.
Can you help me? I've tried a lot of different things!
it's my smartphone? facebook version?
Do you have a simple sample to share a custom (made for user) image with a description in a share dialog?
Thanks and sorry for my english.