Intent on Android

I want to clarify the intention. This is my script. In my project there are 3 events: "A", "B", "C" ..... When I click the "Activity" button "A" , I transfer the values ​​to "B" through the package and based on the value I received a set values ​​from the database ... Similar to "B""C" also ...

The problem is, when I pressed the "Back" button in "C" , it does not go to "B" , but creates an error. Similar to "B " to "A" .

I found the reason why “B” cannot get the value from the package when I press the “Back” button with “C”

I hope you understand. What's the solution....

Thanks in advance

+3
source share
2 answers

Try to get started with startActivityForResultand use setResult(int)to send the result from Activity C to B

0
source

what do you say that the bundle gets null values, so you need to prevent this null value, like the first control packet values, if not non-zero, then only set

Intent myintent = getIntent();
if (null != myintent.getExtras()) {
    // do your work here
    String Name = myintent.getExtras().getString("Name");
} else {
    // not here you can't get values
    // so getting force close here
    Toast.makeText(getApplicationContext(), "No Recor Here..", 12).show();
}
0
source

Source: https://habr.com/ru/post/1770302/


All Articles