get socialize doubts

any one using socialize’s sdk? i want to upload a picture to fb using their sdk but i dont really know how to…anyone tried?

Sure… follow their docs on how to do it. Or this…


protected File getScreenshot(View view) {
    View v = view.getRootView();
    Boolean oldCacheSetting = v.isDrawingCacheEnabled();
    v.setDrawingCacheEnabled(true);
    Bitmap b = v.getDrawingCache();
    v.setDrawingCacheEnabled(oldCacheSetting);
    String extr = Environment.getExternalStorageDirectory().toString();
    File myPath = new File(extr, "screenshot.jpg");
    FileOutputStream fos = null;
    try {
            fos = new FileOutputStream(myPath);
            b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
            fos.flush();
            fos.close();
            MediaStore.Images.Media.insertImage(getContentResolver(), b, "Screen", "screen");
    } catch (FileNotFoundException e) {
            e.printStackTrace();
    } catch (Exception e) {
            e.printStackTrace();
    }
    return myPath;
}
	
public Uri getImageContentUri(File imageFile) {
    String filePath = imageFile.getAbsolutePath();
    Cursor cursor = this.getContentResolver().query(
    MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
    new String[] { MediaStore.Images.Media._ID },
    MediaStore.Images.Media.DATA + "=? ",
    new String[] { filePath }, null);
    if (cursor != null && cursor.moveToFirst()) {
            int id = cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID));
            Uri baseUri = Uri.parse("content://media/external/images/media");
            return Uri.withAppendedPath(baseUri, "" + id);
    } else {
            if (imageFile.exists()) {
                ContentValues values = new ContentValues();
                values.put(MediaStore.Images.Media.DATA, filePath);
                return this.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
            } else {
                return null;
            }
    }
}
	
protected void postScreenshotToSocialize(View v) {
    	File myFile = getScreenshot(v);
    	final Uri image = getImageContentUri(myFile);
    	
    	final Entity entity = Entity.newInstance("Socialize Entity name here", null);
    	final Activity context = this;
    	
    	// First create a Socialize share object so we get the correct URLs
    	ShareOptions options = ShareUtils.getUserShareOptions(context);
    	
    	SocialNetwork[] where_to_share = {SocialNetwork.FACEBOOK };

    	ShareUtils.registerShare(context, entity, options, new ShareAddListener() {
    		@Override
    		public void onError(SocializeException error) {
    		}
    		
    		@Override
    		public void onCreate(Share result) {
    			// We have the result, use the URLs to add to the post
    			PropagationInfo propagationInfo = result.getPropagationInfoResponse().getPropagationInfo(ShareType.FACEBOOK);
    			String link = propagationInfo.getEntityUrl();

    			// Now post to Facebook.
    			Map<String, Object> postData = new HashMap<String, Object>();
    			
    			try {
    				
    				// Format the picture for Facebook
    				byte[] imageData = FacebookUtils.getImageForPost(context, image);
    				
    				// Add the photo to the post
    				postData.put("photo", imageData);
    				
    				PrefsCacheManager sharedPrefs = PrefsCacheManager.getInstance();
    				String msg = "Share message users see";
    				
    				// Add the link returned from Socialize to use SmartDownloads
    				postData.put("caption", msg + link);
    				
    				// Add other fields to postData as necessary
    				
    				// Post to me/photos
    				FacebookUtils.post(context, "me/photos", postData, new SocialNetworkPostListener() {
    					@Override
    					public void onNetworkError(Activity parent, SocialNetwork network, Exception error) {
							if (parent != null) {
								if (!parent.isFinishing()) {
									Activity_BaseClass p = (Activity_BaseClass)parent;
	    							p.displayMessageDialog("Failure", "Facebook servers did not respond.");
								}
							}
    					}
    					@Override
    					public void onCancel() { }
						@Override
						public void onAfterPost(Activity parent, SocialNetwork socialNetwork, JSONObject responseObject) {
							if (parent != null) {
								if (!parent.isFinishing()) {
									Activity_BaseClass p = (Activity_BaseClass)parent;
									p.displayMessageDialog("Success", "Picture posted to Facebook!");
								}
							}
						}
    				});			
    			}
    			catch (Exception e) {
    				displayMessageDialog("Failure", "Internal error in 3rd party code.  This will be fixed in an update.

Your screenshot was saved to your Gallery as the file 'screenshot.jpg'");
    			}
    		}
    	}, where_to_share);
    	
    }

Be warned… there is a bug in Facebook’s SDK. If you post a message, and while the message is being posted, the current activity closes… the FB SDK will crash your app with a nullptr, since it does not check the Activity is still valid before calling the return callback.

Thanks mind , i followed their docs to the word, the only place where i was(and still am) is the entity part , what should i enter in their dashboard and in my code. You’ve solved my code part , but im still confused with dashboard part :slight_smile:

an entity is like a unique id of your piece of content. could be unique id of an article or your picture :wink:

thanks guys,a quick question, what do i need to put in my dashboard for the entity if im uploading an image through my phone , I use fb’s sdk to upload images , but twitter4j sucks like anything , so this is the only way i can think of at the moment…

nevermind guys, with some random tinkering i’ve managed twitter and fb :slight_smile: thanks for the help

Did you find much improvement in downloads etc. with twitter/facebook integration ?

@adforandroidapps
Not really sure if the OP can answer, seems he just integrated it.

Would be good to hear from @mind, about his experience.

@adforandroidapps : nope… I have not observed ANY increase in downloads or any virality as per their marketing spiel.

This is why: Google uses links pointing back to the play.google.com/your_app_here address to determine how many people are interested in it. This is just ONE of the things used in calculating your app’s rank in the lists. Socialize masks their URL’s and does a redirect though their webservers. So Google only ever sees posts pointing to Socialize… and NOT to your app.

However, my Anagram Hero users use the ‘leave a comment’ functionality for realtime user support questions…

Thoughts:

Is it useless: no
Did I integrate it correctly: I don’t know
Did it perform like their marketing guff says it would: no
Did I have to get them to fix bugs before I could use it: yes
Were they responsive and awesome to deal with: yes!
Will I integrate it into WordHero: yes

Thanks for your comments on the Google Play ranking impact of the socializing aspect (i.e. back links to GP webpage etc.).

However, original intent of my question was impact of socializing on “organic download” - i.e. real proliferation of user interest etc.

For example as exemplified by Candy Crush game - where it’s popularity (beyond just popular to phenomenally popular) by the social aspect (most prominently facebook) - where mostly non-tech type folks hear from all their friends about how they are playing it and then they also try to compete etc.

A factor that may play there is a degree of critical mass - for “normal” apps (non-mainstream interest) the impact of social maybe some - but not huge. But if an app IS pretty famous to begin with, perhaps facebook may case a 10x improvement in that. That is, if an app is primed for virality, then maybe facebook can do wonders. For others maybe it has some incremental impact (of the type suggested by mind).

My main point of interest is when user uploads a photo, fb shows, uploaded from “xxx”(eg. instagram or even your app) , this in turn makes users aware of the app, and by deep linking you can even drive traffic to your page(im going to try this tonight) , with twitter i have a #myappname which provides similar benefit. The level of exposure will obviously change from app to app. I have seen many ios apps watermarking their names on user pics too, i tried the same but users were really pissed off, subtle differences between ios and android users :wink:

I also am thinking about creating an fb page, a user can like it from the app using socialize , is that done by you guys?