Android Open Source - PortAuthority Get Hostname Async Task






From Project

Back to project page PortAuthority.

License

The source code is released under:

GNU General Public License

If you think the Android project PortAuthority listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.aaronjwood.portauthority.async;
// w  w  w .  j  a  v  a  2s .  c o m
import android.os.AsyncTask;
import android.util.Log;

import com.aaronjwood.portauthority.response.HostAsyncResponse;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class GetHostnameAsyncTask extends AsyncTask<String, Void, String> {

    private static final String TAG = "GetHostnameAsyncTask";
    private HostAsyncResponse delegate;

    public GetHostnameAsyncTask(HostAsyncResponse delegate) {
        this.delegate = delegate;
    }

    @Override
    protected String doInBackground(String... params) {
        String ip = params[0];
        try {
            InetAddress add = InetAddress.getByName(ip);
            return add.getHostName();
        }
        catch(UnknownHostException e) {
            Log.e(TAG, e.getMessage());
        }
        return null;
    }

    @Override
    protected void onPostExecute(String result) {
        delegate.processFinish(result);
    }
}




Java Source Code List

com.aaronjwood.portauthority.activity.HostActivity.java
com.aaronjwood.portauthority.activity.MainActivity.java
com.aaronjwood.portauthority.async.GetExternalIpAsyncTask.java
com.aaronjwood.portauthority.async.GetHostnameAsyncTask.java
com.aaronjwood.portauthority.async.ScanHostsAsyncTask.java
com.aaronjwood.portauthority.async.ScanPortsAsyncTask.java
com.aaronjwood.portauthority.network.Discovery.java
com.aaronjwood.portauthority.network.Host.java
com.aaronjwood.portauthority.network.Wireless.java
com.aaronjwood.portauthority.response.HostAsyncResponse.java
com.aaronjwood.portauthority.response.MainAsyncResponse.java
com.aaronjwood.portauthority.runnable.ScanHostsRunnable.java
com.aaronjwood.portauthority.runnable.ScanPortsRunnable.java