AppCompatActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { // This adds items to the AppBar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } }
First param is the context // Second param is the activity to launch Intent i = new Intent(ActivityOne.this, ActivityTwo.class); // Put data into the bundle for access in the second // activity i.putExtra("username", "deonna"); // Bring up the second activity startActivity(i); } // ActivityTwo.java protected void onCreate(Bundle savedInstanceState) { // Can access any data passed from ActivityOne String username = getIntent().getStringExtra("username"); doSomethingWithUsername(username); }
in new activity Intent Finish new activity Start new activity from MainActivity https://guides.codepath.com/android/Using-Intents-to-Create-Flows#passing-data-to-launched-activities
any value we want // REQUEST_CODE is used to determine the result type later private final int REQUEST_CODE = 20; public void onClick(View view) { Intent i = new Intent(MainActivity.this, ComposeActivity.class); startActivityForResult(i, REQUEST_CODE); }
is launched for a result public void onDone(View v) { EditText tweet = (EditText) findViewById(R.id.tweet); Intent data = new Intent(); // Pass relevant data back as a result data.putExtra("new tweet", tweet.getText().toString()); setResult(RESULT_OK, data); // Close the activity and pass data to parent finish(); }
into in 2020 that you want to continue? what is your favorite app? how would you improve it? if you could be a kitchen appliance what would you be? what was the last truly great show you’ve watched or book you’ve read? android or iOS?