android network is not working what i should do ???? this code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

android network is not working what i should do ???? this code

package com.skewness.infor; import android.app.Activity; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import java.net.InetAddress; import java.net.MalformedURLException; import java.net.URL; import java.net.UnknownHostException; public class Main2Activity extends Activity { TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState ); setContentView( R.layout.activity_main2 ); Intent intent = getIntent(); String message = intent.getStringExtra( "uri"); try { InetAddress address = InetAddress.getByName(new URL(message).getHost()); String ip = address.getHostAddress().toString(); textView=(TextView)findViewById( R.id.textView4 ); textView.setText(ip); } catch (UnknownHostException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } } }

28th Nov 2018, 9:01 PM
ALAMOUDI, WAEL MAKKI S
ALAMOUDI, WAEL MAKKI S - avatar
1 Answer
0
Are you have specified permission in mainfest file?
16th Dec 2018, 1:14 PM
Katsu Ryuu |
Katsu Ryuu | - avatar