Warum kann ich Gmail nicht aus einer App starten

S

surf_andre

Neues Mitglied
0
Hallo zusammen,
bin neu hier im forum und beschäftige mich seit lurzem mit der App programmierung für Android.
Ich habe mir ne kleine App gebastelt die mir eine Datei mit Daten erstellt.

Nun möchte ich die Daten über ein E-mail programm verschicken. Diesen Programmteil rufe ich aus einem Popup menue auf.
Der Chooser zeigt mir verschiedene Möglichkeiten auf womit ich verschicken kann. Wenn ich auf Email gehe dann öffnet sich auch eine das Email-programm.
Nur wenn ich auf Gmail klicke dann git es eine Exeption
"Die Anwendung Google Mail (Prozess...) wurde unerwartet beendet....

Habe ein LG Optimus Black p970 auf dem ich das teste
Im Emulator geht noch nicht mal der Chooser auf...

Was habe ich da denn falsch gemacht....



Code:
    public void sendEmail() {

      Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
      emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      emailIntent.putExtra(Intent.EXTRA_STREAM,
          "file://sdcard/***.txt");
      emailIntent.setType("plain/text");

      startActivity(Intent.createChooser(emailIntent, "Send email using"));
Gruß André
 
Guck doch mal was die Exception aussagt. In Eclipse hast du unter DBMS ja den kompletten Log des Emulatur bzw. angeschlossenen Gerätes.
Im Log steht meistens eine recht ausführliche Ursachen-Beschreibung der Exception.
So kann man ja nur raten woran es liegen könnte..

Deine letzte Zeile kommt mir aber unvollständig vor, ich würde es zumindest so machen:
Code:
context.[COLOR=#006633]startActivity[/COLOR][COLOR=#009900]([/COLOR]Intent.[COLOR=#006633]createChooser[/COLOR][COLOR=#009900]([/COLOR]emailIntent, "Send email using"[COLOR=#0000FF]));
[/COLOR]

Ich könnte mir aber auch vorstellen, dass deine Datei nicht gefunden wird, weil der Pfad evtl. anders lautet. Z.B. heißt die SD-Karte anders.
 
ok das werde ich heute abend ein mal testen. Hatte bis jetzt mit dem emulator getestet bzw die apk direkt aufs Handy installiert ohne den Debuggmodus zu verwenden...

Gruß Andre
 
so habe das mal mit dem Handy debuggt. Da bekomme ich dann im Logcat eine Nullpointer Execption...
Code:
03-19 18:52:21.160: W/Bundle(17438): Key android.intent.extra.STREAM expected Parcelable but value was a java.lang.String.  The default value <null> was returned.
03-19 18:52:21.160: W/Bundle(17438): Attempt to cast generated internal exception:
03-19 18:52:21.160: W/Bundle(17438): java.lang.ClassCastException: java.lang.String
03-19 18:52:21.160: W/Bundle(17438):     at android.os.Bundle.getParcelable(Bundle.java:1116)
03-19 18:52:21.160: W/Bundle(17438):     at com.google.android.gm.ComposeArea.initFromExtras(ComposeArea.java:670)
03-19 18:52:21.160: W/Bundle(17438):     at com.google.android.gm.ComposeActivity.initFromExtras(ComposeActivity.java:1470)
03-19 18:52:21.160: W/Bundle(17438):     at com.google.android.gm.ComposeActivity.finishOnCreateAfterAccountSelected(ComposeActivity.java:1007)
03-19 18:52:21.160: W/Bundle(17438):     at com.google.android.gm.ComposeActivity.onCreate(ComposeActivity.java:257)
03-19 18:52:21.160: W/Bundle(17438):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-19 18:52:21.160: W/Bundle(17438):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-19 18:52:21.160: W/Bundle(17438):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-19 18:52:21.160: W/Bundle(17438):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-19 18:52:21.160: W/Bundle(17438):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-19 18:52:21.160: W/Bundle(17438):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-19 18:52:21.160: W/Bundle(17438):     at android.os.Looper.loop(Looper.java:123)
03-19 18:52:21.160: W/Bundle(17438):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-19 18:52:21.160: W/Bundle(17438):     at java.lang.reflect.Method.invokeNative(Native Method)
03-19 18:52:21.160: W/Bundle(17438):     at java.lang.reflect.Method.invoke(Method.java:521)
03-19 18:52:21.160: W/Bundle(17438):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
03-19 18:52:21.160: W/Bundle(17438):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
03-19 18:52:21.160: W/Bundle(17438):     at dalvik.system.NativeStart.main(Native Method)
03-19 18:52:21.160: D/AndroidRuntime(17438): Shutting down VM
03-19 18:52:21.168: W/dalvikvm(17438): threadid=1: thread exiting with uncaught exception (group=0x40020c18)
03-19 18:52:21.168: E/AndroidRuntime(17438): FATAL EXCEPTION: main
03-19 18:52:21.168: E/AndroidRuntime(17438): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.gm/com.google.android.gm.ComposeActivity}: java.lang.NullPointerException
03-19 18:52:21.168: E/AndroidRuntime(17438):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at android.os.Looper.loop(Looper.java:123)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at java.lang.reflect.Method.invokeNative(Native Method)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at java.lang.reflect.Method.invoke(Method.java:521)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at dalvik.system.NativeStart.main(Native Method)
03-19 18:52:21.168: E/AndroidRuntime(17438): Caused by: java.lang.NullPointerException
03-19 18:52:21.168: E/AndroidRuntime(17438):     at com.google.android.gm.provider.Gmail$AttachmentOrigin.localFileExtras(Gmail.java:2121)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at com.google.android.gm.ComposeArea.addAttachment(ComposeArea.java:706)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at com.google.android.gm.ComposeArea.initFromExtras(ComposeArea.java:671)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at com.google.android.gm.ComposeActivity.initFromExtras(ComposeActivity.java:1470)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at com.google.android.gm.ComposeActivity.finishOnCreateAfterAccountSelected(ComposeActivity.java:1007)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at com.google.android.gm.ComposeActivity.onCreate(ComposeActivity.java:257)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-19 18:52:21.168: E/AndroidRuntime(17438):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-19 18:52:21.168: E/AndroidRuntime(17438):     ... 11 more
aber warum ich den bekomme habe ich noch nicht gefunden... weiß jemand was dazu...

danke schon mal

Andre
 
Dateiname als Uri angeben und nicht als String beim Extra Stream?

Gesendet von meinem R800i mit der Android-Hilfe.de App
 
boah... wie blöd

danke hat geklappt...


Andre
 

Ähnliche Themen

R
  • Robby1950
2
Antworten
23
Aufrufe
1.022
Robby1950
R
Laser5001
  • Laser5001
Antworten
2
Aufrufe
900
Laser5001
Laser5001
Manny87
  • Manny87
Antworten
11
Aufrufe
166
swa00
swa00
Zurück
Oben Unten