I have a specific problem:
I have a Android 1.6 device that uses bluetooth to connect to a smartphone (android) and use tethering to access internet...
Bluetooth itself cannot be used for anything else except that connection.
It also doesn't have a wifi.
Now, I'm trying to make an app for that device that will connect to a "server" app on the smartphone!
What is the easiest way of doing this? I have a simular app running but I have to manualy type the IP of the "server" (if smartphone is on wifi).
Can I somehow programatically get the IP of the tethering smartphone or something if it using bluetooth tethering?
Thanks!
You could run a terminal emulator on your smartphone and try running the following commands:
getprop net.dns1
ip addr show
ip route show
netcfg
Perhaps you can run those commands from within your app? Otherwise, you would have to read through the Android API manual, which can be found here.
UPDATE: as of Android Nougat 7.x, ifconfig is present, and netcfg is gone.
This question, also seems to be related and may be of use.
Related
I have successfully managed to install the Android Things Dev Preview onto my Raspberry Pi.
I have a problem though. When I first started installing my own applications I was able to connect to the Raspberry Pi through Ethernet, because it displayed the IP address on the TV when I booted up the Raspberry Pi.
Now because I have the Raspberry Pi already running an application, when I boot it up, it is automatically booting into my application without showing the initial screen with the IP address (and I forgot my IP address 🤔).
Is there an easy way to get the IP address of the Raspberry Pi, or connect to it when I don't know the IP address? Even a command to get a list of all available ADB devices on the network would help.
It would be great if when connected to a certain Wi-Fi, you could run something like:
adb network devices
Which could give a list of ADB devices on the network you are on.
The Raspberry PI Automatically broadcasts Android.local and should resolve to the IP address assigned to your Pi on port 5555.
Running the following:
adb connect Android.local
The command above is effectively the same as running:
adb connect <ip-address>:5555
Note: This will only work if your host platform supports multicast DNS service discovery.
This information was found in the documentation here by step 7 https://developer.android.com/things/hardware/raspberrypi.html
You can scan your network for points with ports 5555/5554 open, for example,
nmap -p 5555,5554 192.168.0.2-100
will scan in range 2-100 for any IP addresses with those ports open.
Or you can check in your router which devices are connected
On OS X you can scan for all devices that publish itself as Android.local
dns-sd -Q Android.local
I believe you need Bonjour on Windows/Linux to get something similar, but I'm still not familiar with them.
After figuring out the correct IP for the desired device you can connect as usual:
adb connect <ip-address>:5555
If multicast DNS is not supported on host platform and you have access to your router, you can simply log into it and view the list of connected devices.
You will be able to view all the devices no matter if mDNS is available or if there are any ports opened on the device (or if you don't know which port is opened).
The easiest way how to get to the initial screen with IP address from your application is to connect a USB keyboard to your Raspberry Pi then pressing escape key once :)
I had the very same problem recently and the easiest way in my opinion is that to just install a simple app on your phone (in my case Fing) that shows all the connected devices to your local connection including th RPI with their ip address. So then you are good to go!
Hi as of yesterday I was able to build and push apk files to the ADT-1 Android TV device via WiFi. Then the device had an update and now I'm no longer able to connect to the device. I think the port number adb is allowed to connect on has changed... but to what?
Yes I've made sure the IP address is valid and am using the port number 4321. Pinging the device works. But its giving me the error:
unable to connect to 10.0.0.86:4321:4321
I've tried to connect via ethernet and WiFi. Both fail.
I directly hooked it up to a laptop and manually forced it to use port 4321 again via: "adb tcpip 4321"
Now I can connect with my main dev computer from across the room again.
Grumpf. Look like they removed the necessary "service.adb.tcp.port=4321" from build.prop in 5.0.2.
Why, oh why?
I want to write a program ,which will communicate to the available android mobile device via wi-fi .(Note :I do not want to use the USB cable)
That moblile device is having an IP in it by a wi-fi connection with it.The major thing is that i pinged that IP and I am getting connection packets getting back to my pc,means I can communicate with the devices. so can I able to get the details of the device.
details means
1.its name what user sets on it.
2.some address like mac in computers.
3.model name.
4.type of os in it.
etc
I really find this interesting but,no idea how to do but i got something like ARP protocol for getting the mac address but I do not know how to communicate with a phone with this ARP protocol.
Can we communicate by the SSH as it a linux kernel based OS .Kindly give me a way how to get these information.
can any one have some idea ,kindly tell me,it is very important for my project.
Thanks
There is adbWireless application. If you install it on your device, a widget appears that allows you to connect with it over WiFi. In Toast message it shows IP address of Android device.
Then on your PC type:
adb connect 192.168.1.102
(replace it with Android IP address).
And now you have an access to your phone over WiFi (check it with adb devices).
You need rooted phone to use adbWireless.
I need network connection on my Android device to test apps. My notebook WiFi adapter is broken, so after 2 hours I've set connection via USB. But! Eclipse doesn't see the device when I start "Wired Tether" on it to get connection and I can't debug my apps.
Does anybody know how to solve this issue? Use USB tethering to get internet connection on phone and debug apps at the same time?
I don't know of a way to simultaneously use USB debugging and tethering. Here are some workarounds, though:
Get a USB wireless adapter for your computer (see http://www.amazon.com/gp/bestsellers/electronics/13983791/ref=pd_zg_hrsr_e_2_4_last). I don't know if buying one of these is an option for you in India.
Send your apk to your phone wirelessly for app installation (see Developing on android-based device via wireless) and then view the logcat directly on the phone for debugging (aLogcat seems to be popular, and allows you to send log files via, for example, email, so that you can open them on your computer to view them on a bigger screen)
I know these solutions involve some cost, effort, or inconvenience, but hopefully one will work for you.
EDIT:
As noted in answers from #shkschneider and #CodeShane, Internet sharing via Bluetooth is possible. CodeShane's answer mentions PdaNet (which apparently also allows for simultaneous USB tethering and debugging), and includes a link. Another solution is OpenGarden. These solutions provide access to the Internet for the computer via the phone. If the reverse is desired (and this is not entirely clear from the question), reverse tethering seems to be the answer (see the answer from #NickL).
Long story short: you can't. Android simply does not supports it (that is more because of the USB standard and tethering action than AOSP's fault).
So to go around the problem, you should either:
Get internet form another source
Maybe you could have ethernet connection?
Tether internet from your phone to your netbook in another way
You can't use wireless tether since your wifi adapter is broken, but maybe you could tether using bluetooth?
Debug your phone in another way
Maybe you could use an android application like aLogCat or similar?
But in the hand, sorry, you can't tether usb from phone to netbook while usb debugging from the netbook. Your success will depend on your ability to find an alternative solution.
I would like to point out that I am using PDANet for USB-tethered internet to type this reply while I am also debugging an android application on the same phone via Eclipse Juno. Not sure which side fixed this, but it is awesome!
As for why Eclipse isn't seeing your device, standard troubleshooting tips apply .. make sure to enable USB debugging and unknown sources/3rd party apps, try restarting, check usb drivers, update drivers/eclipse..
Device not detected in Eclipse when connected with USB cable
http://developer.android.com/tools/device.html
Eclipse not finding phone
PdaNet 3.5
Eclipse Juno Service Release 1; Build id: 20120920-0800
You can use bluetooth tethering to get internet connection and debug using USB.
Step 1. Turn off USB tethering
Step 2. Turn on Wireless USB Debugging
Connect to your device via USB
Enter "adb tcpip 5555"
Unplug your device
Look up your device's IP in the system settings
Enter "adb connect [ip address]:5555"
Step 3. Turn on USB tethering
Now you can use internet via USB cable and debug app in wireless mode
That's it!
Yes, its possible. There's a hack available at below links !
Source: HowToGeek , StackOverFlow
You can actually connect the adb to the phone via TCP. You may need a rooted phone for this to work, though
If I understand your question correctly, you want to tether your phone to the PC via USB, and use the (internet)connection of your PC + still get logcat output?
Then yes, this certainly is possible.Tethering is when your PC uses the internet of your phone, the other way around is called reverse tethering. Your device has to be rooted, then you can use this application for reverse tethering.
When you connect your phone to the computer via USB, you press 'connect' in the application. It then installs an app on your phone, which handles the reverse tethering connection. It works, I sometimes have to press 'check DNS' while it is connecting to make it working.. but it works! Also debugging via USB works the usual way.
First you need to debug your device using USB cable then type adb tcpip 5555 it will allow debugging via TCP/IP protocol.
After that turn on your USB tethering, now your computer get internet connection but lost the USB debugging.
Now you must know your phone IP address so you can debug via TCP/IP. You can use command arp -a in terminal and look at the gateway address.
The last is connect to your phone using adb connect yourphoneip:5555 for example adb connect 192.168.42.129:5555
Now you get debug and tether at the same time
You can use
WiFi Tethering - For Internet connection
Connect USB for adb.
First : I know about abdWireless app. But my problem is different.
I am using my Android mobile as Mobile AP (Portable WiFi hotspot) for using internet on my computer. I want to use adb in wireless mode but the problem is - when i enable Mobile AP on my android mobile WiFi gets turned off and i am unable to use abdWireless app.
I want to use both wireless ADB and Mobile AP at the same time.
Is there any way to do it ???
Developers have created apps for this:
https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb
Once you start this app, you can connect to your phone like this:
adb connect ip_address_of_the_device
However, your phone must be rooted!
Please let me know if this helps!
On mac:
You need to run: ifconfig
Followed by run: arp -a
In my case, the first listed IP is router IP, ie. IP of your android device with hotspot(let it be: ip_address_of_the_hotspot_device).
Then run either: adb connect ip_address_of_the_hotspot_device or adb connect ip_address_of_the_hotspot_device:5555