I want to Share photo to facebook via intent from specific url.
http://tineye.com/images/widgets/mona.jpg
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse("http://tineye.com/images/widgets/mona.jpg");
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
From galllery its working fine.
But when I pass above url to intent photo not share on facebook.
Help me for this......
for posting image from web url you will do following steps :
STEP 1: get bitmap from URL :
see this post
How to load an ImageView by URL in Android?
for getting image bitmap from URL
STEP 2 :
Store Bitmap in Images.Media temporarily and after send it you can delete it
String path = Images.Media.insertImage(getContentResolver(),
bitmapiamge, "title", null);
Uri screenshotUri = Uri.parse(path);
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
emailIntent.setType("image/png");
startActivity(Intent.createChooser(emailIntent, "Send email using"));
and for sending bitmap to facebook wall see this post :
Code to set the background image to the relative layout from one activity to another
in the first activity see the code shown below
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
// TODO Auto-generated method stub
if(requestCode == 1011)
{
if(resultCode == RESULT_OK)
{
image.setImageURI(data.getData());
imageUri = data.getData();
String filePath[] = {MediaStore.Images.Media.DATA}; //A column name which to be return
Cursor c = getContentResolver().query(imageUri, filePath, null, null, null);
c.moveToFirst();
int index = c.getColumnIndex(filePath[0]);
String path = c.getString(index);//actual path of file in sa card
c.close();
if(path!=null)
{
//Bitmap bmp =BitmapFactory.decodeFile(path);
SharedPreferences.Editor editor = pref.edit();
editor.putString("image",path);//set the path of file into the SharedResources
editor.commit();
}
}
}
}
code to set background image
void setLayoutBackground()
{
SharedPreferences pref = getSharedPreferences("style_pref", 0);
String path = pref.getString("image",null);
Bitmap myBitmap = BitmapFactory.decodeFile(path);
BitmapDrawable d = new BitmapDrawable(getResources(),myBitmap);
layout.setBackgroundDrawable(d);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.