Is it a correct way to compare Intents? I never get in to the if/else regardless the incoming Intent is android.Intent.action.VIEW (the value intent.getAction() returns):
private void handleIntent(Intent intent) {
Log.d(TAG, intent.getAction()); // -> android.Intent.action.VIEW
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
ShowToast.showToast(this, "Something..."); // Never get here
} else if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
showResults(query);
}
}
Update: Why does the intent.getAction() returns android.Intent.action.VIEW (capital ‘i’) while it should return android.intent.action.VIEW as in specification?
I found where the capital ‘i’ came from. As long as I’m using the
SearchViewI specify whatIntentto be used when newActivitywould start by myself, so I just made a mistake here: