In my application, I made my content provider searchable by specifying my main action as the default search activity for my manifest.
<activity android:name="com.pt.application.MainActivity" android:label="@string/title_activity_map" android:launchMode="singleTop" android:theme="@style/AppTheme" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.SEARCH" /> </intent-filter> <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" /> </activity>
Then I applied the onSuggestionClick option to update the map based on the offer clicked by the user. Searchview is in the action bar. The problem is that when the user clicks on the sentence, the activity is somehow recreated (I think that OnPause and OnResume are called?). Is there any way to prevent this? I donβt want my activity to be βrecreatedβ every time a user clicks on an offer.
If more code is required, please ask. Thanks.
EDIT: code added
<?xml version="1.0" encoding="utf-8"?> <searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="@string/app_name" android:hint="@string/search_hint" android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" android:voiceLanguageModel="web_search" android:searchSuggestAuthority="com.pt.provider" android:searchSuggestIntentData="content://com.pt.provider/busstop"> </searchable>
In my main activity:
source share