android searchable not opening
Posted
by
ng93
on Stack Overflow
See other posts from Stack Overflow
or by ng93
Published on 2011-01-02T18:36:56Z
Indexed on
2011/01/02
21:53 UTC
Read the original article
Hit count: 471
Hi im trying to use a searchable activity in my application but when the search button is pressed nothing happens
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test.test" android:versionCode="1" android:versionName="1.0.0" android:configChanges="keyboardHidden|orientation">
<uses-sdk android:minSdkVersion="7"/>
<application android:icon="@drawable/icon" android:label="Test">
<activity android:name=".Test" android:label="Test" android:debuggable="true" android:theme="@android:style/Theme.NoTitleBar" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".Searchable">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/>
</activity>
<meta-data android:name="android.app.default_searchable" android:value=".Searchable"/>
</application>
</manifest>
Searchable.xml (res/xml/searchable.xml)
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="Search" android:hint="Perform Search">
</searchable>
Searchable.java (src/com/test/test/Searchable.java)
package com.test.test;
import android.app.Activity;
import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;
public class Searchable extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
handleIntent(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
handleIntent(intent);
}
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
}
}
}
TIA,
ng93
© Stack Overflow or respective owner