Fotos vom Handy in eine App reinladen

  • Antworten:2
NewAndroidGuy
  • Forum-Beiträge: 62

05.12.2012, 16:29:54 via Website

Hallo an alle ich hätte gerne, dass der Benutzer als Hintergrund der Activity ein Bild laden kann aber irgendwie funktioniert ein Beispiel aus dem Inetrnet bei mir nicht:

void is an invalid type for the variable onActivityResult -> im Internet benutzten jedoch alle protected void

public Bitmap getImage(){

Bitmap image;

Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);


protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK)
{
Uri chosenImageUri = data.getData();

Bitmap mBitmap = null;
mBitmap = Media.getBitmap(this.getContentResolver(), chosenImageUri);
image = mBitmap;
}

return image;
}

}

Wäre schön, wenn mir jemand zeigen könnte warum das nicht funktioniert, weil ich von diesem Kapitel in Android keine Ahnung habe

— geändert am 05.12.2012, 16:31:04

Antworten
San Blarnoi
  • Forum-Beiträge: 2.545

05.12.2012, 19:06:50 via Website

weil ich von diesem Kapitel in Android keine Ahnung habe

Mit Android hat das nichts zu tun, sondern mit Java allgemein...

1. "protected void onActivityResult(int requestCode, int resultCode, Intent data)" ist bei dir eine lokale Funktion, sowas gibts in Java mW nicht

2. protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
...
return image;
}

Ja, was denn nun? Returnwert oder nicht? :P

Antworten
NewAndroidGuy
  • Forum-Beiträge: 62

05.12.2012, 19:09:46 via Website

Ja klar das war der Fehler :D

Ich glaub ich sollte mal schlafen gehen :D

Antworten