1 package net.yacy.yacyAndroid;
3 import java.io.BufferedReader;
4 import java.io.IOException;
5 import java.io.InputStreamReader;
6 import java.util.ArrayList;
8 import net.yacy.rss.Feed;
9 import net.yacy.rss.RSSFeedParser;
11 import org.apache.http.HttpResponse;
12 import org.apache.http.client.ClientProtocolException;
13 import org.apache.http.client.methods.HttpGet;
14 import org.apache.http.client.methods.HttpPost;
15 import org.apache.http.impl.client.DefaultHttpClient;
17 import android.app.Activity;
18 import android.net.ConnectivityManager;
19 import android.content.Context;
20 import android.os.Bundle;
21 import android.view.View;
22 import android.widget.EditText;
23 import android.widget.Toast;
25 public class YacyAndroidActivity extends Activity
27 // Beispiel: http://search.yacy.net/yacysearch.html
28 // ?query=tagesspiegel&Enter=Search&verify=false
29 // &nav=hosts%2Ctopics%2Cfiletype&startRecord=0
30 // &resource=global&urlmaskfilter=.*&prefermaskfilter=
31 // &indexof=off&meanCount=5&maximumRecords=10
32 StringBuilder url = new StringBuilder("http://search.yacy.net/yacysearch.rss?query=");
33 String urlRest = new String("&Enter=Search&verify=false&nav=hosts%2Ctopics%2Cfiletype&startRecord=0&resource=global&urlmaskfilter=.*&prefermaskfilter=&indexof=off&meanCount=5&maximumRecords=10");
35 /** Called when the activity is first created. */
37 public void onCreate(Bundle savedInstanceState)
39 super.onCreate(savedInstanceState);
40 setContentView(R.layout.main);
43 /** Send the search-query to yacy */
44 public void onClickBtnSend(View view)
46 Context context = getApplicationContext();
47 final DefaultHttpClient client = new DefaultHttpClient();
49 final HttpResponse response;
50 final EditText eingabe;
51 final StringBuilder tmp = new StringBuilder();
52 final RSSFeedParser parser = new RSSFeedParser();
54 final ArrayList liste;
58 eingabe = (EditText)findViewById(R.id.eingabe);
59 url.append(eingabe.getText());
61 get = new HttpGet(url.toString());
62 response = client.execute(get);
64 BufferedReader rd = new BufferedReader(new InputStreamReader(
65 response.getEntity().getContent()));
68 while ((line = rd.readLine()) != null)
74 liste = parser.readFeed(tmp);
75 //Toast toast = Toast.makeText(context, tmp.toString(), Toast.LENGTH_LONG);
78 catch (ClientProtocolException e)
80 // TODO Auto-generated catch block
85 // TODO Auto-generated catch block
88 Toast toast = Toast.makeText(context, "Programmende", Toast.LENGTH_LONG);