android


Android IP fetching


we are doing a chat application using android 2.3.3 as a project, when we open the application we need to fetch the IP address automatically through code and send it to the server with status.How it can be done. We 'll be grateful for any help regarding this topic.
Thanks in advance
Tak a look here Get IP address
And don't forget to add the line
<uses-permission android:name="android.permission.INTERNET" />
to the manifest
Why would you send the IP to the server? The server can get the IP when the client connect?
Normally the client would have to know the IP to the server and connect to it. Under some circumstances it could be hard or impossible to tell what IP it will get when it reaches the server (NAT firewalls, proxies, multiple networking devices such as 3G, wifi etc.).
To list all IP addresses registered on your Android device you could do (code from http://www.droidnova.com/get-the-ip-address-of-your-device,304.html):
public String getLocalIpAddress() {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress().toString();
}
}
}
} catch (SocketException ex) {
Log.e(LOG_TAG, ex.toString());
}
return null;
}
I suggest that you read up on client/server architectures. There are several guides on this topic.
http://pguides.net/java/tcp-client-server-chat
http://pirate.shu.edu/~wachsmut/Teaching/CSAS2214/Virtual/Lectures/chat-client-server.html

Related Links

view android.widget.linearlayout is not a slidingdrawer
How to change custom-action-bar for several fragment in android?
Grid View Custom View issue : java.lang.ClassCastException?
how to set NO item found in listview if there is not item in list in android
How to fill color over other color on imageview area in android?
About android Sqlite safety in multi-process case
How to start activity as its first created
Android Not able to share correct text from viewpager
Images not loading using Picasso no error given
How to implement rotate animation ProgressDialog with asynctask
PhoneStateListener acting weird?
How to bring up the set default launcher prompt?
Why VIBRATOR_SERVICE is not working consistently?
SQLite how to query a string value and return a value in a different column
Disable physical keyboard for certain edittext fields in android
Android process killed; is this log a normal “killed process”- log (no uncaught exception?)

Categories

HOME
azure-stream-analytics
jpa
datastore
jelastic
solver
access
cakephp-3.4
bookmarks
vsm
android-json
fhir
heap
siddhi
frequency-distribution
atlassian
altera
gruntfile
scsi
sse
sencha-touch
apache2.4
simpleitk
drive
ksh
squashfs
gulp-watch
react-toolbox
exit
object-storage
epsilon
windows-server-2003
google-cloud-print
interbase
shared
underscore.js
exchangewebservices
openmdao
userdefaults
panoramas
paragraph
dynamic-jasper
least-squares
imx6
servicestack-text
video-capture
sharepoint-workflow
cd
projects-and-solutions
ods
typesafe-config
laravel-elixir
levenshtein-distance
skylink
softmax
congestion-control
flask-restful
fwrite
carrot2
qtranslate
context-sensitive-grammar
colorbar
bbpress
smartfoxserver
cudd
cubism.js
flex-monkey
jboss-tools
ng-grid
appscale
stream-processing
data-protection
halcon
invoke-sqlcmd
contentcontrol
ascii-art
java-money
themoviedb-api
page.js
.bash-profile
sapscript
mass-assignment
easyrtc
universal-image-loader
gii
android-framework
dsym
synapse
rolify
tlf
nevron
subproject
thttpd
oracle-enterprise-linux
koken
binomial-heap
application-planning
dsoframer

Resources

Encrypt Message