powered by Jive Software

UserSearchManager can not work

hi all.

l am developing a android client with asmack,l have a problem using UserSearchManager to search user on server,the console show nullPointException as follows;

10-28 03:15:18.790: E/AndroidRuntime(1596): java.lang.NullPointerException

10-28 03:15:18.790: E/AndroidRuntime(1596): at com.openfirejunit.MainActivity.search(MainActivity.java:51)

this is my code:

ProviderManager manager = ProviderManager.getInstance();

manager.addIQProvider(“query”, “http://jabber.org/protocol/disco#items”, new DiscoverItemsProvider());

manager.addIQProvider(“query”, “http://jabber.org/protocol/disco#info”, new DiscoverInfoProvider());

UserSearchManager usm = new UserSearchManager(conn);

Form searchForm = null;

try {

List services = new ArrayList();

services.addAll(usm.getSearchServices());

// Out.println("service "+services.get(1));

searchForm = usm.getSearchForm(services.get(1)); //here is line 51,show nullPointException

Out.println("null "+(searchForm==null)); // here console 10-28 03:39:22.471: I/System.out(8220): null true

// Out.println("type "+searchForm.getType());

Form answerForm = searchForm.createAnswerForm();

answerForm.setAnswer(“last”, “liu”);

ReportedData data = usm.getSearchResults(answerForm,

host);

when running,it shows services.get(1) is “search.wechat.com” service;

I am happy to know if anyone has similar problems or has possible fixes already.