Using an Android device I connect to the Theta camera to shoot 360 photos. Till API level 28, our existing code works fine, but with the new API 29, wifi(hotspot) connection functions are deprecated and with the new NetworkSpecifier function, I can connect to the device; but I can’t not make any API request to the Theta camera.
Like GET http://192.168.1.1/osc/info request always fail, even in mobile web-browser.
Error Message:
Caused by: java.net.ConnectException: failed to connect to /192.168.1.1 (port 80) from /:: (port 0) after 10000ms: connect failed: ENETUNREACH (Network is unreachable)
Here is my code snap to connect to the Theta camera.
final WifiNetworkSpecifier specifier = new WifiNetworkSpecifier.Builder()
//.setSsidPattern(new PatternMatcher(ssid, PatternMatcher.PATTERN_PREFIX))
.setSsid(ssid)
.setWpa2Passphrase(passPhrase)
.setBssid(MacAddress.fromString(i.BSSID))
.build();
final NetworkRequest request = new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.setNetworkSpecifier(specifier)
.build();
final ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
final ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(@NonNull android.net.Network network) {super.onAvailable(network);}
@Override
public void onUnavailable() { super.onUnavailable();}
@Override
public void onLost(@NonNull android.net.Network network) { super.onLost(network);}
};
//connectivityManager.registerNetworkCallback(request, networkCallback);
connectivityManager.requestNetwork(request, networkCallback);
As I said, i can connect to the Theta camera and my Android device wifi connection shows, ‘Connected via MyApp’. But the API’s to communicate with the device always fail. NOW, if I manually connect the device by going into my device wifi settings and select the Theta camera, then it works fine. To make it hassle free, we don’t want our customers to go to device settings to change connection every time.
Please post the camera model and firmware version. For example, THETA V with 3.50.1 or THETA Z1 with 1.60.1.
this may take us some time to replicate.
To confirm, your Android app has the targetSdkVersion set to “29”, meaning that you’re building it so that users can’t use an older version, correct?
If this is for a large commercial deployment, suggest you also contact @jcasman by DM or email as he may be able to assist with organizing and sending the information to RICOH.
From November 2020, all Android apps required targetSdkVersion 29 and over. Otherwise, Google play store will not accept that app to be released. So, we have been forced to upgrade our Android app targetSdkVersion to 29.
We are not large yet. But we customers who use our app to take 360 photos using Theta V and Z1(a few). But I am using Theta V for testing.
I want to be straightforward with you on the situation.
@jcasman and I manage this independent forum and have regular communication with RICOH, but we don’t work for RICOH
@jcasman and I are not professional software developers. We can test basic apps and code snippets with the camera, but we do not have expert knowledge on programming.
If the problem is beyond our ability, we need to report the problem to our contacts at RICOH in Tokyo.
Here’s my plan for a course of action:
organize information on the Google statement about API 29 requirements and also comments from the Android Developer community. Have you seen any discussions on StackOverflow about problems with migrating to API 29? I’m assuming this is going to be a big problem for many people? Is Google really not going to accept a target below 29? I see that their developer site has information this, but maybe there are complaints from the Android developer community?
I will attempt to replicate the problem with my own tests. If I can successfully replicate the problem, I will send RICOH the organized information from Google along with my own tests
I’ll make a recommendation to @jcasman to contact other Android developers that are building RICOH THETA apps and see if there are encountering the same problem.
Regardless of the status of my own tests, I’ll make a recommendation @jcasman to contact RICOH about this. However, it is better if we send them organized information along with comments from real people like you. If we can get more developers to say it is a problem, then we may get more help.
Hi Craig, Thank you so much for your support and really appreciate your time. I thought this forum is own by RicohTheta. This is a big change from Google in 3rd party device connectivity.
Well the good news is that, I was able to figure out the issue. I need to bind the new network(Theta Camera) for all the outgoing traffic. It’s not mentioned in Android developer forum. I found a suggestion in stackoverflow to bind the network, then I applied it and it is working now. So on network availability we need to do that. below is the code -
Awesome!! Thank you for sharing the solution. This is super useful.
This forum does receive sponsorship from RICOH and we do have ways to communicate RICOH staff. However, the process is slow and our ability to make progress is based on the requests from the community.
Thank you for taking the time to join the community and write this positive comment. It helps us show the value of the community to our sponsors at RICOH. Also, thanks to @saleh for contributing this information.