Android DNS MX record lookup
Question
I want to lookup dns mx records an the android platform.
When using http://www.dnsjava.org on android new Lookup("gmail.com", Type.MX).run();
always returns null.
import org.xbill.DNS.Lookup;
import org.xbill.DNS.MXRecord;
import org.xbill.DNS.Record;
import org.xbill.DNS.TextParseException;
import org.xbill.DNS.Type;
List<String> targets = new ArrayList<String>();
Record[] records;
records = new Lookup("gmail.com", Type.MX).run();
for (int i = 0; i < records.length; i++) {
MXRecord mx = (MXRecord) records[i];
targets.add("Host " + mx.getTarget() + " has preference "+ mx.getPriority());
}
Any ideas or alternatives? Thanks!
Solution
Finally forgot to set the permission and unfortunately no exception has been thrown...
<uses-permission android:name="android.permission.INTERNET" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow