Android Activity for result aus Dialog

kurztipp

Aktives Mitglied
Hallo,

ich möchte eine Activity aufrufen, um von ihr ein Ergebnis zu erhalten. Funktioniert mit
Code:
startActivityForResult()
und
Code:
onActivityResult()
auch wunderbar, allerdings nur, wenn es beispielsweise von einem Button o.ä. direkt aus der Activity oder vom Kontextmenü aufgerufen wird.
Ich würde es aber ganz gerne aus einem Dialog aufrufen. Der Code hierfür:
Java:
public class AddDialog extends DialogFragment {
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setNeutralButton("Hinzufügen", new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (which == DialogInterface.BUTTON_NEUTRAL) {
                    Intent intent = new Intent(getActivity(), AddActivity.class);
                    startActivityForResult(intent, 0);
                }
            }
        });
    }
}
Die Subactivity wird auf aufgerufen und es wird zur aufrufenden Activity zurückgewechselt, aber
Code:
onActivityResult
wird nicht aufgerufen.
Hängt wohl mit dem Fragment zusammen. Hat jemand einen Lösungsvorschlag?

Gruß
 
Zuletzt bearbeitet:
Ähnliche Java Themen
  Titel Forum Antworten Datum
M Activity einer anderen App mit result Android & Cross-Platform Mobile Apps 2
W JSONARRAY per Intent an andere Activity übergeben und umwandeln ggbf. Android & Cross-Platform Mobile Apps 1
CT9288 Methode von Fragment durch Activity rufen scheitert Android & Cross-Platform Mobile Apps 7
ruutaiokwu Android Daten von "Activity A" nach "Activity B" umleiten? Android & Cross-Platform Mobile Apps 13
L Android Lockscreen-Sperrmuster activity verwenden Android & Cross-Platform Mobile Apps 1
J Android App stürzt ab wenn neue activity gestartet Android & Cross-Platform Mobile Apps 6
D Android Activity wechseln per Button Android & Cross-Platform Mobile Apps 3
P Android Android-App Crash - Unable to start activity ComponentInfo Android & Cross-Platform Mobile Apps 2
S Neue Activity lässt sich nicht starten Android & Cross-Platform Mobile Apps 28
B Android Activity nach gedrückte Returntaste weiterlaufen lassen Android & Cross-Platform Mobile Apps 2
J Probleme mit ViewPager und Activity Android & Cross-Platform Mobile Apps 1
B Android In einem View der ersten Activity zweite anzeigen Android & Cross-Platform Mobile Apps 2
G Accelerometer ohne Activity Android & Cross-Platform Mobile Apps 8
J Android BroadcastHandler extends BroadcastReceiver; auf Activity zugreifen? Android & Cross-Platform Mobile Apps 5
K Android Übergeordnete Activity herausfinden? Android & Cross-Platform Mobile Apps 7
W Android Designfrage / Layout / Activity / Fragments Android & Cross-Platform Mobile Apps 2
B Login Activity Android & Cross-Platform Mobile Apps 1
M Android Suche Activity/View Namen Android & Cross-Platform Mobile Apps 1
K Unbekannte Menge von Daten (Strings oder Ints) an Activity übergeben Android & Cross-Platform Mobile Apps 0
M Fehler ohne Sinn? java.lang.RuntimeException: Unable to start activity ComponentInfo Android & Cross-Platform Mobile Apps 11
S Android Eclipse erstellt keine main Activity Android & Cross-Platform Mobile Apps 4
B java.lang.RuntimeException: Unable to start activity ComponentInfo Android & Cross-Platform Mobile Apps 2
S Android "Weiches wechseln" zwischen Views in einer Activity Android & Cross-Platform Mobile Apps 3
D Android Activity mit mehreren Views "spliten" Android & Cross-Platform Mobile Apps 10
G Activity-Wechsel bitte ohne Notification Android & Cross-Platform Mobile Apps 6
G eine Methode einer anderen Activity aufrufen Android & Cross-Platform Mobile Apps 9
D Android Neue Activity im TabWidget laden Android & Cross-Platform Mobile Apps 8
S Android In Service überprüfen ob eine Activity gebunden ist? Android & Cross-Platform Mobile Apps 6
T Android Activity finished testen Android & Cross-Platform Mobile Apps 5
T Activity / Application fundamentals Android & Cross-Platform Mobile Apps 4
M Activity wechseln aus List View mit Android & Cross-Platform Mobile Apps 2
G extends Activity für Berechnungen? Android & Cross-Platform Mobile Apps 7
G Daten von einer Activity zur nächsten übergeben Android & Cross-Platform Mobile Apps 6
G selbes Menü auf jeder Activity Android & Cross-Platform Mobile Apps 4
C Activity ohne Aktion starten Android & Cross-Platform Mobile Apps 8
C Android Kommunikation zwischen Service und Activity Android & Cross-Platform Mobile Apps 8
Maxim6394 [ Android ] Activity ändern Android & Cross-Platform Mobile Apps 9
A Activity Intent 'source not found' Android & Cross-Platform Mobile Apps 4
A Android Activity Variablen-Initialisierung Android & Cross-Platform Mobile Apps 8
A Beenden einer 2ten Activity Android & Cross-Platform Mobile Apps 3
W Standard Gallery Activity? Android & Cross-Platform Mobile Apps 22
schlingel Android: Overlay in Activity Android & Cross-Platform Mobile Apps 3
G Activity beenden Android & Cross-Platform Mobile Apps 2
S Rechnen mit Json Result Android & Cross-Platform Mobile Apps 2
R Android Dialog verstecken, statt zu schliessen Android & Cross-Platform Mobile Apps 7
J Input Dialog - ist das so richtig ? Android & Cross-Platform Mobile Apps 1
L Leerer Dialog Android & Cross-Platform Mobile Apps 0
L Dialog anzeigen wenn auf Button gedrückt wird. Android & Cross-Platform Mobile Apps 4
B Android Alert Dialog mit sound oder Android & Cross-Platform Mobile Apps 1
J Dialog in Fragment Android & Cross-Platform Mobile Apps 6
B Senden via Dialog? Android & Cross-Platform Mobile Apps 6
N Android Retain Dialog verschwindet beim drehen Android & Cross-Platform Mobile Apps 4
T Android - Toast Dialog oder was anders? Android & Cross-Platform Mobile Apps 3
A Android Probleme mit Dialog Android & Cross-Platform Mobile Apps 4
A Android Dialog wird nicht sofort angezeigt Android & Cross-Platform Mobile Apps 12
L Custom Dialog Button event Android & Cross-Platform Mobile Apps 2
I modaler Dialog Android & Cross-Platform Mobile Apps 2

Ähnliche Java Themen

Neue Themen


Oben