Answered by Intent With Extras
I have an upload activity with two results returned by the server.
Result 1: Data Upload Successful. Result 2: Upload Not Successful.
I added a third result of intent not being received (e.g device data off, or device has no data bundles). How can i return these and set textviews to a message of these depending on what was returned?
ResultsACtivity.java
public class SuccessActivity extends AppCompatActivity {
public TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.success_main);
getSupportActionBar().setTitle("Data Upload Results");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
textView = findViewById(R.id.experiences);
String data;
String data2 = "Your Data Upload Was NOT Successfull!!";
Intent intent = getIntent();
Bundle bundle = getIntent().getExtras();
if (bundle.containsKey("VAL1")) {
data = bundle.getString("VAL1");
textView.setText(data);
}
else {
textView.setText(data2);
}
VAL1 is data results returned by the server. (1. "Upload Successful" or null.