Versenden von Bildern

N

NewPerson1

Neues Mitglied
0
Hallo,
ich möchte gern ein Bild versenden mittels impliziten Intents.
Das Bild befindet sich im einen Path ("/FotoApp/bild.png").
Auf der Activity kann ich das Bild anzeigen lassen, aber das Versenden funktioniert leider nicht.

Das Problem: Ich kann die App öffnen (z.B. WhatsApp), aber wenn ich einen Benutzer aussuche ist das Bild immer schwarz. Und wenn ich bei WhatsApp dann auf senden geh kommt immer eine Fehlermeldung.

Ich hoffe ihr könnt das Problem finden. :)

Code:
public class SendActivity extends Activity implements OnClickListener{

	Button bSend;
	ImageView ivBild;
	Bitmap bm1;
	int Kameracode = 15;
	
	File bildfile = new File(Environment.getExternalStorageDirectory() + "/FotoApp/bild.png");
	Uri bilduri = Uri.fromFile(bildfile);
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.send);
		
		bSend = (Button) findViewById(R.id.bSend);
		bSend.setOnClickListener(this);
		ivBild = (ImageView) findViewById(R.id.ivBild);
		if (bildfile.exists()){
			bm1 = BitmapFactory.decodeFile(bildfile.getAbsolutePath());
			ivBild.setImageBitmap(bm1);		
			}
	}
		
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.bSend:
			Intent shareIntent = new Intent();
			shareIntent.setAction(android.content.Intent.ACTION_SEND);
           // bm1 = BitmapFactory.decodeFile(bildfile.getAbsolutePath());
            Uri screenshotUri = Uri.parse("/FotoApp/bild.png");
            shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, screenshotUri);
            shareIntent.setType("image/png"); 
            shareIntent.setPackage("com.whatsapp"); 
            startActivity(Intent.createChooser(shareIntent, "Share using"));            
			break;
		}
	}
}

Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="2 Seite"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <Button
        android:id="@+id/bSend"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Send" />

    <ImageView
            android:id="@+id/ivBild"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:src="@drawable/ic_launcher"
            android:layout_marginTop="250dp"
            android:layout_marginLeft="70dp"/>

</LinearLayout>
 
Ich hab den Fehler gefunden, aber ich weiß nicht wie ich den Fehler lösen soll?

So funktioniert es, aber mit dem Falschen Bild.
Ich möchte das Bild gern aus einem File holen und dieses dann versenden.
Code:
Uri screenshotUri = Uri.parse("android.resource://com.camera.paier/drawable/"+R.drawable.ic_launcher);           
            Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
            shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, screenshotUri);
            shareIntent.setType("image/*"); 
            startActivity(Intent.createChooser(shareIntent, "Share using"));

Also muss ich die Uri ändern, aber wie? So funktioniert es leider nicht.
Code:
Uri screenshotUri = Uri.parse("/FotoApp/bild.png")
 

Ähnliche Themen

S
Antworten
17
Aufrufe
554
jogimuc
J
B
Antworten
6
Aufrufe
1.051
jogimuc
J
5
Antworten
22
Aufrufe
1.420
590239
5
Zurück
Oben Unten