Android Eclipse: Sharing image to facebook without mediaStore.Insert() -


i share screenshot facebook, twitter, etc, using intent. have found code examples achieve inserting image media store , grabbing uri image. however, not want clog user's device these useless images, , not want ask access external permission, not use anywhere else in app. there way build intent such share image without having have uri? passing bitmap directly, or passing after compressing .png? or there way build uri bitmap held in memory, without first making file?

i using now:

public void sharescore(string scoretextstring, string scorestring, uri screenshoturi){               intent sharingintent = new intent(android.content.intent.action_send);               sharingintent.settype("image/png");              sharingintent.putextra(android.content.intent.extra_stream, screenshoturi);              startactivity(intent.createchooser(sharingintent, "share via..."));     }  public bitmap takescreenshot(gl10 mgl) {             final int mwidth =  this.getglview().getwidth();     final int mheight = this.getglview().getheight();     intbuffer ib = intbuffer.allocate(mwidth * mheight);     intbuffer ibt = intbuffer.allocate(mwidth * mheight);     mgl.glreadpixels(0, 0, mwidth, mheight, gl10.gl_rgba, gl10.gl_unsigned_byte, ib);      // convert upside down mirror-reversed image right-side normal image.     (int = 0; < mheight; i++) {         (int j = 0; j < mwidth; j++) {             ibt.put((mheight - - 1) * mwidth + j, ib.get(i * mwidth + j));         }     }             bitmap mbitmap = bitmap.createbitmap(mwidth, mheight,bitmap.config.argb_8888);     mbitmap.copypixelsfrombuffer(ibt);           return mbitmap; }  private uri getimageuri(context incontext, bitmap inimage) {         bytearrayoutputstream bytes = new bytearrayoutputstream();         inimage.compress(bitmap.compressformat.png, 100, bytes);         string path = images.media.insertimage(incontext.getcontentresolver(), inimage, "title", null);              return uri.parse(path);     }  private void share(){     string scoretextstring = "i set new high score on butterfly bonanza!";     string scorestring = "score :" + integer.tostring(score);                    uri screenshoturi = getimageuri(glgame.class.cast(game), butterflybonanza.class.cast(game).getscreenshot());     butterflybonanza.class.cast(game).sharescore(scoretextstring, scorestring, screenshoturi); } 

an uri points file, there no way create uri bitmap in memory.

like pointed out, attach image directly intent, this:

 bytearrayoutputstream bos = new bytearrayoutputstream();    yourbitmap.compress(compressformat.png, 0, bos);      intent intent = new intent();   intent.setaction(intent.action_send);   intent.settype("*/*");   intent.putextra(intent.extra_stream, bos.tobytearray());  startactivity(intent);  

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -