Android add domain and ip to hosts file programmatically - android

I want to set temporary domain and ip to hosts file. which only activate when the app is running. i want to make app work like Hosts go which works well on not rooted too.
what i'm trying to do is the server is running on Lan computer. so when app load that domain load it from Lan server.
i tried google but all i can find is DnsResolver. can anyone guide me please?
Thanks!

Related

How to connect an android app running on a device connected via ADB to hit REST API on local server?

I have a multi-tenant web app like
http://xxxxx.constant-domain.com:8080/
in my host file
127.0.0.1 xxxxx.constant-domain.com
The device that has the android app running is connected via ADB which calls my webapp's Rest Apis to get and send data and
It runs fine on dev and prod environments like
http://xxxxx.dev.constant-domain.com/get-data
but the problem is I want to debug it on my local server. I tried adding the given domain as base url but it doesn't work.
I tried adding http://localhost:8080/ as well but it doesn't work.
I tried looking for questions here but didn't find anything that would help.
I'm using retrofit for Api calls.
Any help would be appreciated.
First of all, make sure that your local server and your device are using a same wifi. And then find out the option to put your local server online. There is an option in Wamp Server to put it online. I don't know which software you are using to setup apache or any kind of server on your computer.
And then you will be able to access your local server by ip address. Also there is an option to edit virtual hosts of your server to allocate a specific port that the app can connect.
It doesn't matter whether you use Retrofit or Volley or Okhttp or any other things. You need to setup your local server to be online within your local network.
I figured it out. All I needed to do was to set my private Ip as
http://192.168.8.400:8080/get-data
Hope this helps anyone who is in this situation.

How to intercept mobile traffic on Android?

I have a device (videocamera) with Android inside.
I have root access via ADB to the OS of the videocamera.
The camera sends data to the internet using a SIM card.
Is there a way to redirect the mobile traffic to a proxy, so that I could research it?
1) Seems that an apk like ProxyDroid may help, but it lacks the command line interface.
2) I tried redirecting the traffic using Access Point Name (APN), but is did not help.
The common tool for this is Charles Proxy, but you'd need to be able to install certificates on the host device.

Is it possible to access a local website without modifying the hosts file?

TL;DR: I have access to the localhost on my iPhone but can't reach local websites because I have no access to the host file.
Hi everyone,
I have a local website that uses a CMS setup on my laptop. The binding is specified correctly in IIS and reachable on my laptop. By getting the local address (192.168.xxx.xxx) and opening the appropriate ports, I am able to reach the localhost on my desktop computer and my iPhone. By adding the host name to the host file on my desktop, I am able to reach the website. So far so good!
However, I am not able to reach the site on my iPhone as I have no access to the hosts file. I tried setting up a binding that specifies the IP address and a set port (192.168.xxx.xxx:port) with limited success, the site was reachable but the CMS I am using on my site requires a hostname to function correctly. I want to be able to reach the site using an Android phone as well if possible, but again, I have no access to the host file.
I know its possible to fix this with DNS forwarding but I don't have access to the router over the network I am using.
Is it possible to specify the hostname in the url along with the IP address? Something like 192.168.xxx.xxx:hostname? If this is possible, I will be able to access the site on my iPhone and also on Android phones.
Any advice would be greatly appreciated, thank you!
OK I found an alternative to all this by forcing my phone to use the host file on my laptop. I found the answer here:
https://stackoverflow.com/a/6385967/2398998

add host and ip address to access remote web services in Android

I am trying to access a web service remotely(outside the firewall) and i am able to access it from my laptop( where i added IP Address and Host Name) in C:\Windows\System32\drivers\etc\hosts file.
But, i am unable to do the same from an Android App as i don't have a rooted phone. I can root my phone but at the end other users should also be able to use this app. How to achieve that?
What should be the ideal course of action to access remote web services if this app needs to be distributed to end users in the future.
Kindly, advise.
Thanks

Access Java Web application running on a server by Android device thru wifi

I have searched for a solution to this but could not find one. If this is already answered, sorry, please direct me to that.
My problem is this. I have java web application running on a local intranet (Tomcat 7, Java 6, MySQL). All desktops within the intranet are connected thru LAN and access the application using the specific server IP, something like 198.162.2.10.
Now, I want to access this thru my android mobile phone as well. The entire building is Wifi enabled and I'm able to access this web application, if I know the IP and enter it in the mobile browser. But, I would like to make this mobile access automatic and wrap it in an app which on click access this automatically, even when the IP changes. We have dynamic IPs.
You can use WebView component to display a web page within your application.
As alternative you can use HttpURLConnection co perform Http request and posts to your web application.
Regarding the dynamic IP you can configure a Local dns server or assign a static IP to the server.
Anyway the application need a fixed address to connect to the web application, unless you want to insert the address manually each time.

Categories

Resources