requestRouteToHost always returns false on AVD

by Tina » Tue, 20 Jul 2010 21:59:08 GMT


Sponsored Links
 Hi, all!
I need to check web site availability and use requestRouteToHost  for
that purpose. On real device everything works fine, but on emulator
requestRouteToHost  always return "false".
What's wrong?
Code is:

public static boolean isHostAvailable(Context context, String
urlString) throws UnknownHostException, MalformedURLException {
                boolean ret = false;
                int networkType = ConnectivityManager.TYPE_WIFI;
                ConnectivityManager cm = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
                if(cm != null){
                        NetworkInfo nf = cm.getActiveNetworkInfo();
                        if(nf != null){
                                networkType = nf.getType();
                        }
                        URL url = new URL(urlString);
                        InetAddress  iAddress = 
InetAddress.getByName(url.getHost());
                        ret = cm.requestRouteToHost(networkType,
ipToInt(iAddress.getHostAddress()));
                }
                return ret;
}

--



Other Threads

1. SJXP 2.0 Released - Simple XML Parsing in Android

Simple Java XML Parser (SJXP) 2.0 is released.

SJXP is a very light weight (4 class) abstraction to XML Pull Parsing
on Android (and Java in general) that allows you to use XPath-like
expressions in parsing without needing to worry about while loops,
event handling, try-catch blocks, etc.

A quick example of parsing story links from an RSS feed would look
like this:
=================
IRule linkRule = new DefaultRule(Type.CHARACTER, "/rss/channel/item/
link") {
        @Override
        public void handleParsedCharacters(XMLParser parser, String
text, Object userObject) {
                // Also store the link, or something equivalently
fancy
        }
}

XMLParser parser = new XMLParser(linkRule);
parser.parse(xmlInputStream);
=================

You just specify a type for the rule, provide a path in the XML you
want parsed and then override 1 of 3 default no-op handlers and then
you can just sit around waiting for data to show up at your doorstep.
Namespaces are also supported, please see the project page for a lot
more documentation, examples and benchmarks.

Performance + Ease of Use is the big win and the design focus of SJXP.


New and Noteworthy
===============
* Memory usage and CPU usage are a magnitude times smaller than what
they were in 1.x series. Spent some quality time with HPROF finding
and removing hotspots.
* A new TAG type of rule is supported if you are just analyzing XML
metrics and don't want the overhead of parsing data out of it.
* Support for user-object passthrough was added to make it easier to
get at data stores inside of the handlers.


Project: http://www.thebuzzmedia.com/software/simple-java-xml-parser-sjxp/
Download: 
https://github.com/downloads/thebuzzmedia/simple-java-xml-parser/sjxp-2.0.zip


SJXP is licensed under the Apache 2 license.


Good or bad feedback is appreciated!

-- 

2. Android on PB11MPCORE

Hi guys
I am a bit new to this so pardon me if this is a naive question.
I am trying to boot android on a PB11MPCORE arm board. I have already
got the kernel image (zimage) and the system.img and data.img ( for
android) built for this board( it a fryo build) .
I want to now boot this on my device. I have tried looking but I
haven't found any documents for this part. How do I go about trying to
boot from this point on . The board has a boot monitor which gives me
a prompt at power up.
I will greatly appreciate if some could give me a few details on this
so that I can boot android on this board.

Rahul

-- 

3. Aapt.exe keeps crashing with ADT 10.

4. Request a webpage and display in app

5. java.lang.VerifyError error at the time of using gson library on HTC desire

6. Recent Changes text not sticking

7. [WTShare] Smzone, aplikasi penjadwalan sms berdasarkan lokasi