Searchable activity being called twice

后端 未结 2 368
野性不改
野性不改 2021-02-04 08:25

I\'m trying to create my first Android app and in the process of adding to it SEARCH functionality. I\'ve followed the Android Developer documentation to add both the Search dia

相关标签:
2条回答
  • 2021-02-04 08:47

    I think methods onNewIntent and onCreate are mutually exclusive. You set launchMode to "singleTop", so the method onNewIntent would be called and not the onCreate.

    I have a similar problem when one search request is processed twice. Working with the SearchableDictionary sample in the WXGA 10.1 tablet emulator I found that the first search call works fine, but consequent calls create two SEARCH events, so they are processed twice. Somebody mentioned about a bug in Ti. (http://developer.appcelerator.com/question/127166/android-search-keyboardtype-fires-return-event-twice )

    I tested apps on a real Samsung tablet and I didn’t see two SEARCH events, so I guess it’s an emulator problem, not a code problem.

    0 讨论(0)
  • 2021-02-04 08:54

    Try to remove super.OnNewIntent(intent) in your SearchableActivity.

    According to your manifest you are trying to use search dialog

    <meta-data
    android:name="android.app.default_searchable"
    android:value="com.shop.SearchableActivity" />
    

    and in the same time you use SearchView in your Menu. If you use SearchView you should use

        <meta-data android:name="android.app.searchable"
                   android:resource="@xml/searchable"/>
    

    like in http://developer.android.com/guide/topics/search/searchable-config.html.

    That is my example of xml/searchable.xml:

    <searchable xmlns:android="http://schemas.android.com/apk/res/android" 
        android:label="@string/app_name"
        android:hint="@string/search"
        android:searchSuggestAuthority="@string/authority"
        android:searchSuggestSelection=" ?"
        android:voiceSearchMode="launchRecognizer">
    </searchable>
    
    0 讨论(0)
提交回复
热议问题