how to use jmdns

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


Sponsored Links
 I!
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. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_printers);

showAllPrinters();
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.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View
view,
int position, long id)
{
// When clicked, show a toast with the
TextView text
Toast.makeText(getApplicationContext(),
((TextView)
view).getText(),
Toast.LENGTH_SHORT).show();

if (jmdns != null)
{


ListPrinters.jmdns.removeServiceListener("_http._tcp.local.",
listener);
ListPrinters.jmdns.close();
ListPrinters.jmdns = null;
ListPrinters.impl = null;


}
}
});

this.listener = new ServiceListener() {

public void serviceAdded(ServiceEvent event) {

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

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

public void serviceResolved(ServiceEvent event)
{
PrinterList.add("Service resolved: " +
event.getInfo());
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 <naveen...@gmail.com> wrote:
>


Sponsored Links


Other Threads

1. Is it possible to include the cupcake plugins jar into my app?

Hi All,

I'm developing an app for the google challenge, my problem is that I'm
relying on the MapView which is still not on any market device (I
think). Seen that to win, people must vote for you, no one will be
able to install the app on his phone. Is the MapVien including native
calls? otherwise did someone try to integrate the plugins jar into his
app?

Any feedbak is very welcome,
Regards,
Zied Hamdi

--~--~---------~--~----~------------~-------~--~----~

2. Android 1.5 - getNeighboringCellInfo() always returns 0 neighboring cells

Has anyone been able to retrieve the neighbor cell information using a
G1 or ADP phone?

I'm using android-sdk-linux_x86-1.5_r2 and compiling against API level
3 (Android 1.5).
The application builds correctly but every time I request the
neighboring cells as listed below, it returns a list of 0 neighbors.
If I look at the radio log buffer, I can see the request being made to
the RIL layer.

Is anyone else seeing this?

Here are the permissions in AndroidManifest.xml
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-
permission>
<uses-permission
android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></
uses-permission>
<uses-permission
android:name="android.permission.ACCESS_COARSE_UPDATES"></uses-
permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></
uses-permission>

Here is the code:

        // Retrieve the telephony manager
        mTelephonyManager = (TelephonyManager)getSystemService
(Context.TELEPHONY_SERVICE);

        // Get the neighbor cell information
        ArrayList<NeighboringCellInfo> neighbors =
(ArrayList<NeighboringCellInfo>)
mTelephonyManager.getNeighboringCellInfo();

        Log.d(TAG, "Number Of Neighbors: " + neighbors.size());

        // Print out the neighbor cells
        for (NeighboringCellInfo neighboringCellInfo : neighbors) {

            Log.d(TAG, "NeighborCell: " + neighboringCellInfo);
        }

Any help would be greatly appreciated!

--~--~---------~--~----~------------~-------~--~----~

3. Unable to initialize Repo client

4. DDMS telephony actions on real connected device?

5. Images are not saved properly

6. MapView drag delay

7. Updating items in ListView