0

Hello I'm new to android studio I have built an app when you take a photo from the camera app see it in an ImageView and share it

I have made a share button:

case R.id.shrbtn:
  startshare();
  break;

the share button go to this method to start sharing the photo I have added internet permission and the button don't do anything:

private void startshare() {
  Bitmap bmp=viewToBitmap(Image,Image.getWidth(),Image.getHeight());
  Intent shareIntent = new Intent(Intent.ACTION_SEND);
  shareIntent.setType("image/*");
  Uri phototUri = Uri.parse(String.valueOf(Bitmap.createBitmap(bmp)));
  shareIntent.setData(phototUri);
  shareIntent.putExtra(shareIntent.EXTRA_STREAM,phototUri);
  startActivity(Intent.createChooser(shareIntent, "Share Via"));
}

can anyone tell me what is missing?

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
Hesham
  • 45
  • 7

2 Answers2

1

Send it by an intent and get it from startActivityForResult() method.

This tutorial explains it well

srs
  • 330
  • 1
  • 11
  • i already have that method but for the button that set the image as wallpaper protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { Bundle extras = data.getExtras(); bmp = (Bitmap) extras.get("data"); Image.setImageBitmap(bmp); } – Hesham Aug 03 '17 at 21:53
0

This sounds to me like an issue regarding the button callback itself. Have you make sure that the method have been called? Maybe you should set breakpoints to identify the issue?

Maybe you should take a look here (as your share intent looks wrong): https://stackoverflow.com/a/7662164/6268503

Mordag
  • 487
  • 7
  • 20
  • i forgot to set the setOnClickListener i set it test the app on my tablet and a pop up show with this no app can perform this action here is my code again Bitmap bmp=viewToBitmap(Image,Image.getWidth(),Image.getHeight()); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); Uri phototUri = Uri.parse(String.valueOf(Bitmap.createBitmap(bmp))); shareIntent.setData(phototUri); shareIntent.putExtra(shareIntent.EXTRA_STREAM,phototUri); startActivity(Intent.createChooser(shareIntent, "Share Via")); – Hesham Aug 03 '17 at 23:42