DiscoverySetup.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2013 Yujin Robot.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
00005  * use this file except in compliance with the License. You may obtain a copy of
00006  * the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
00013  * License for the specific language governing permissions and limitations under
00014  * the License.
00015  */
00016 package com.github.rosjava.android_extras.ros_master_browser;
00017 
00018 import android.content.Context;
00019 import com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf;
00020 import android.app.ProgressDialog;
00021 import android.os.AsyncTask;
00022 
00026 public class DiscoverySetup extends AsyncTask<Zeroconf, String, Void> {
00027 
00028         private ProgressDialog commencing_dialog; 
00029         private final Context context;
00030 
00031         public DiscoverySetup(Context context) {
00032                 this.context = context;
00033         }
00034         
00035     protected Void doInBackground(Zeroconf... zeroconfs) {
00036         if ( zeroconfs.length == 1 ) {
00037             Zeroconf zconf = zeroconfs[0];
00038             android.util.Log.i("zeroconf", "*********** Discovery Commencing **************");
00039             zconf.addListener("_ros-master._tcp","local");
00040             zconf.addListener("_ros-master._udp","local");
00041         } else {
00042                 android.util.Log.i("zeroconf", "Error - DiscoveryTask::doInBackground received #zeroconfs != 1");
00043         }
00044         return null;
00045     }
00046 
00047     protected void onPreExecute() {
00048                 commencing_dialog = ProgressDialog.show(context,
00049                                 "Zeroconf Discovery", "Adding listeners...", true);
00050     }
00051     protected void onPostExecute(Void result) {
00052         commencing_dialog.dismiss();
00053     }
00054 }


android_extras
Author(s): Daniel Stonier
autogenerated on Thu Jun 6 2019 20:13:19