MasterBrowserActivity.java
Go to the documentation of this file.
00001 package ros.zeroconf.android.jmdns.master_browser;
00002 
00003 import java.io.IOException;
00004 import java.lang.Thread;
00005 import java.util.ArrayList;
00006 import java.util.List;
00007 import javax.jmdns.ServiceInfo;
00008 import android.app.Activity;
00009 import android.app.ProgressDialog;
00010 import android.os.AsyncTask;
00011 import android.os.Bundle;
00012 import android.content.Context;
00013 import android.view.View;
00014 import android.view.ViewGroup;
00015 import android.view.LayoutInflater;
00016 import android.widget.ListView;
00017 import android.widget.ArrayAdapter;
00018 import android.widget.AdapterView;
00019 import android.widget.AdapterView.OnItemClickListener;
00020 import android.widget.Toast;
00021 import android.widget.TextView;
00022 import android.text.method.ScrollingMovementMethod;
00023 import ros.zeroconf.jmdns.Zeroconf;
00024 import ros.zeroconf.jmdns.ZeroconfDiscoveryHandler;
00025 import ros.zeroconf.android.jmdns.Logger;
00026 import ros.zeroconf.android.jmdns.master_browser.R;
00027 import ros.zeroconf.android.jmdns.master_browser.DiscoveryHandler;
00028 import ros.zeroconf.android.jmdns.master_browser.DiscoveryAdapter;
00029 import ros.zeroconf.android.jmdns.master_browser.DiscoverySetup;
00030 import org.ros.message.zeroconf_comms.DiscoveredService;
00031 
00032 // adb logcat System.out:I *:S
00033 // adb logcat zeroconf:I *:S
00034 
00053 public class MasterBrowserActivity extends Activity {
00054         
00055         /********************
00056          * Variables
00057          *******************/
00058         private Zeroconf zeroconf;
00059         private Logger logger;
00060         private TextView tv;
00061         private ListView lv;
00062         private ArrayList<DiscoveredService> discovered_services;
00063     private DiscoveryAdapter discovery_adapter;
00064         private DiscoveryHandler discovery_handler;
00065         
00067     @Override
00068     public void onCreate(Bundle savedInstanceState)
00069     {
00070         super.onCreate(savedInstanceState);
00071         android.util.Log.i("zeroconf","*********** Zeroconf Create **************");
00072         discovered_services = new ArrayList<DiscoveredService>();
00073         setContentView(R.layout.main);
00074         lv = (ListView)findViewById(R.id.discovered_services_view);
00075         discovery_adapter = new DiscoveryAdapter(this, discovered_services);
00076         lv.setAdapter(discovery_adapter);
00077         tv = (TextView)findViewById(R.id.mytextview);
00078         tv.setMovementMethod(new ScrollingMovementMethod());
00079         tv.setText("");
00080 
00081         logger = new Logger();
00082                 zeroconf = new Zeroconf(logger);
00083                 discovery_handler = new DiscoveryHandler(tv, discovery_adapter, discovered_services);
00084                 zeroconf.setDefaultDiscoveryCallback(discovery_handler);
00085                 
00086                 new DiscoverySetup(this).execute(zeroconf);
00087     }
00088     
00089     @Override
00090     public void onPause() {
00091         logger.println("*********** Zeroconf Pause **************");
00092                 super.onPause();
00093     }
00094 
00095     @Override
00096     public void onStop() {
00097         logger.println("*********** Zeroconf Stop **************");
00098                 super.onStop();
00099     }
00100     
00101     
00102     @Override
00103     public void onDestroy() {
00104         logger.println("*********** Zeroconf Destroy **************");
00105 //        zeroconf.removeListener("_ros-master._tcp","local");
00106 //          zeroconf.removeListener("_ros-master._udp","local");
00107 //          zeroconf.removeListener("_concert-master._tcp","local");
00108 //          zeroconf.removeListener("_concert-master._udp","local");
00109 //          zeroconf.removeListener("_app-manager._tcp","local");
00110 //          zeroconf.removeListener("_app-manager._udp","local");
00111             try {
00112                 zeroconf.shutdown();
00113         } catch (IOException e) {
00114                 e.printStackTrace();
00115         }
00116                 super.onDestroy();
00117     }
00118 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations


zeroconf_android_master_browser
Author(s): Daniel Stonier
autogenerated on Fri Apr 26 2013 20:45:18