how to use jmdns

by Naveen » Wed, 21 Apr 2010 14:45:12 GMT

Sponsored Links
My goal is to find network printers using jmdns

Following is the code I have written which does not work. I am new to
all this Pls. help me.
What exactly I want to do is to list all printers in list
box...Currently I am not filtering printers..

I am always getting exception... Here is my code

public class ListPrinters extends ListActivity {
public static JmDNS jmdns;
public static JmDNSImpl impl;
protected ServiceListener listener;
protected ServiceInfo info;

public ListView lv;
public ArrayList<String> PrinterList;
public int cancel =0;

public final static String TAG = "ListPrinter";

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {

PrinterList = new ArrayList<String>();
PrinterList.add("First Node"); /// just for checking
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1 , PrinterList));
lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener()
public void onItemClick(AdapterView<?> parent, View
int position, long id)
// When clicked, show a toast with the
TextView text

if (jmdns != null)

ListPrinters.jmdns = null;
ListPrinters.impl = null;


this.listener = new ServiceListener() {

public void serviceAdded(ServiceEvent event) {

PrinterList.add("Service added : " +
event.getName() + "." +
Log.v(TAG,"Service added : " +
event.getName() + "." +

public void serviceRemoved(ServiceEvent event) {
PrinterList.add("Service removed : " +
event.getName() + "." +
Log.v(TAG,"Service removed : " +
event.getName() + "." +

public void serviceResolved(ServiceEvent event)
PrinterList.add("Service resolved: " +
Log.v(TAG,"Service resolved: " +

how to use jmdns

by Bob Kerns » Thu, 22 Apr 2010 04:38:42 GMT

 sually exceptions are your clue as to what went wrong. And debuggers
are your best tool for understanding what triggered that exception,
and where.

Since you don't tell us the exception or where, I'm afraid you have
all the information you'll need to figure this out -- and we do not.

Good luck.

On Apr 20, 11:44pm, Naveen <> wrote:

Sponsored Links

Other Threads

1. How to Put common header for entire application Like Android Market application

Hi all,
I am Working on develop an application .In my application i want to
Put application header as it look like "Android Market Application" .I
need help on following issues.
1)How to put all header same for all activities in the application.
2)How to put the common header like in android market application.
3)How to put a common footer for all activities in application.

If any one knows solution,please tell me,if possible send source code
for my understanding.

Thanks in advance.


2. Custom tabs customizable only to 99%

According to the
example I'm able to use tabbed content, however problems arise if I'm
not satisfied with the default look (well, for my app, I'm not :)

In order to change the tab drawable, I'm using for each TabWidget
child setBackgroundDrawable(...) but this heads to a situation where
small strips on both side of selected tabs are still visible.

Thanks to this post

3. What are your suggestions about it.

4. Integrate ImageButton with ListActivity failed - List no longer selectable.

5. Layout problems: AbsoluteLayout deprecated, how to do it now?

6. HTC Hero Album app source code, anyone ?

7. (x,y) co-ordinates of touched area ?