• @Override the onNewIntent(Intent intent) method.
    • This method handles Intents that do not require our activity to be restarted; instead this event fires when we go back to an Active Activity.
  • Define a custom method to handle various Intents sent to our activity.
    • In lesson, I called mine handleIntent(Intent intent)
  • In your onCreate and onNewIntent methods, call your custom method that handles intents (again, mine was called handleIntent()) and passes our getIntent() or Intent objects.
@Override
public void onCreate(Bundle savedInstanceState) {
    // prior code
    handleIntent(getIntent());
}

@Override
protected void onNewIntent(Intent intent) {
    handleIntent(intent);
}

private void handleIntent(Intent intent) {

}
  • Finally, inside of handleIntent, check to see what type of Intent you have.
    • We can check for search by...
    • Intent.ACTION_SEARCH.equals(intent.getAction()))
  • IF this is a Search action, we want to get our user's query
    • intent.getStringExtra(SearchManager.QUERY)
  • We can then send this data off to a Cursor, to a Toast, to whatever... we just have to tie it all together

results matching ""

    No results matching ""