View Single Post
Old 10-05-2010, 12:53 PM   #9
th0br0
Junior Member
th0br0 began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Oct 2010
Device: Kindle 3G+WiFi
Excellent find. This will get the MPD client I had in mind for a long time done real sone
Should you be evaluating connecting to some non-standard port (such as MPD in my case) it truly is a shame that they only seem to support http and https.

However, what you can still do stuff like this:

Code:
	KTextArea ktx = new KTextArea();

	@Override
	public void start() {
		try {

			ctx.getRootContainer().add(ktx);
			ctx.getConnectivity().submitConnectivityRequest(
					new ConnectivityHandler() {

						@Override
						public void disabled(NetworkDisabledDetails arg0)
								throws InterruptedException {
							// TODO Auto-generated method stub

						}

						@Override
						public void connected() throws InterruptedException {
							try {
								URL testUrl = new URL("http", "192.168.2.100", 6600,
                                "");
								URLConnection con = testUrl.openConnection();
								DataInputStream dis = new DataInputStream(con
										.getInputStream());
								String inputLine;

								while ((inputLine = dis.readLine()) != null) {
									ktx.append(inputLine);
								}
								
							} catch (Exception e) {
								ktx.append("exception: " + e.getMessage());
							}
						}
					});

		} catch (Exception e) {
			System.out.println("Error Connecting:" + e.getMessage());
			e.printStackTrace();
		}
	}
Of course the device still sends that bad HTML Header
But after that

Mind that the nasty downside to this is that you can't be on usbnet while doing this...
Seems that the Kindle thinks that there is no W-Lan connection if usb0 is up

Sucks from my point of view, especially as we have to do the connection via that connectivity handler but it can't be helped i guess.

Last edited by th0br0; 10-05-2010 at 01:42 PM.
th0br0 is offline   Reply With Quote