The endless.solr project simplifies the integration of Apache Solr data into Android applications. It provides a data provider for the endless list library which accesses an Apache Solr server.
A common use case is the search for a specific entry in the Apache Solr index. The user enters a search string and gets a list of hits. endless.solr helps the developer and minimizes the development effort to achieve this.
private static final String SERVER_URL = "http://android-rpgnextgen.rhcloud.com/solr"; private static final String CACHE_DATA_PROVIDER = "cache.data.provider"; private SolrDataProvider dataProvider; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_endless_list); SolrEntryViewProvider entryViewProvider = new SolrEntryViewProvider(getBaseContext(), "name", R.id.entry); GenericArrayAdapteradapter = new GenericArrayAdapter (this, entryViewProvider); adapter.setErrorHandler(new DataProviderErrorHandler(this, "There was a problem getting the data from " + SERVER_URL + ".")); setListAdapter(adapter); if (savedInstanceState == null) { dataProvider = new SolrDataProvider(SERVER_URL, "type:country"); adapter.setDataProvider(dataProvider); // to display the first block of entries on startup // go and fetch the first block of entries here adapter.new QueryTask().execute(); } else { dataProvider = savedInstanceState.getParcelable(CACHE_DATA_PROVIDER); adapter.setDataProvider(dataProvider); } } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (dataProvider != null) { outState.putParcelable(CACHE_DATA_PROVIDER, dataProvider); } }
This Android library works from API level 11 upwards (Android 3.x) and requires the endless list library.
This software is released under the BSD 2-Clause License.
A demo APK showing endless list solr examples can be found in the projects files section. The permission INTERNET is needed to run the demo because the Solr example needs network access to the remote Solr server instance.
The source code can be fetched from Sourceforge.net with the following command
hg clone http://hg.code.sf.net/p/andless/endless.solr endless.solr