revolutionarybreak
revolutionarybreak

Reputation: 15

I can't check any solution for Inet Address in Android

So I'm trying to get the Ips of the websites on my app and I'm having a lot of problem with this one as a newbie I'm searching everywhere but no clue. I tried on intelij and it works fine while on android it gives hell lot of troubles.

Code:

hostnumber = findViewById(R.id.hostnumber);
    output = findViewById(R.id.output);
    submit = findViewById(R.id.submit);
    submit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
        submit.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitNetwork().build();
                StrictMode.setThreadPolicy(policy);
                InetAddress address = null;
                try {
                    address = InetAddress.getByName(String.valueOf(hostnumber));
                } catch (UnknownHostException e) {
                    e.printStackTrace();
                }catch (Exception e) {
                    Toast.makeText(Lookup.this,"Please Check The Url" + e, Toast.LENGTH_SHORT).show();
                }

                output.setText((CharSequence) address);

            }
        });

    }
});

} // on create

I've also added on the manifest file. I looked Around some old threads but looked up and found that this library has been deprecated into kotlin. Any Idea or solution about this?

Upvotes: 0

Views: 168

Answers (0)

Related Questions