4

比較するのは正しい方法Intentsですか?Intent着信がandroid.Intent.action.VIEW(intent.getAction() が返す値) に関係なく、if/else に入ることはありません。

    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);
            }
        }

更新:仕様どおりに返されるはずなのに、(大文字の「i」) が返さintent.getAction()れるのはなぜですか?android.Intent.action.VIEWandroid.intent.action.VIEW

4

1 に答える 1

2

大文字の「i」がどこから来たのかを見つけました。を使用している限り、newが自分で起動するときにSearchView何を使用するかを指定しているので、ここで間違いを犯しました:IntentActivity

<searchable xmlns:android="http://schemas.android.com/apk/res/android"
            android:label="@string/appname"
            android:hint="@string/search_hint"
            android:searchSuggestAuthority="my.package.dataproviders.TicketSuggestionProvider"
            android:searchSuggestIntentData="content://my.package.dataproviders.TicketSuggestionProvider/titleslist"
            android:searchSuggestIntentAction="android.Intent.action.VIEW" // HERE IT IS
            android:searchSuggestSelection=" ?">
</searchable>
于 2012-09-05T10:17:38.567 に答える