Android WebView: where are connections to bc.googleusercontent.com coming from? - android

My app opens a WebView, which in turn loads a simple page from my remote host. Recently I've been trying to minimise the amount of data usage, by maximising cache usage, and have started using a network connections monitor app like this and this to check what connections are actually being made by my app (and others).
These are showing that, as well as a connection being made to the host when the webview loads, a connection is also being made to nnn.n.nnn.nn.bc.googleusercontent.com. The first of the above apps resolves this to an admin address of Google Inc.
But I have no idea why this connection is being made. My webpage does not have any google-related tracking code or anything like that, has no links to adverts, nothing at all along those lines. And the Android app itself, that loads the WebView, likewise does not at any point try to fetch "user content" from googleusercontent.com.
I would post some code, but since I have no idea where this call is initiated from, I wouldn't know what to show. I would also say that I have noticed on my phone that occasionally a full-page advert will pop up, and I have no idea where it's coming from... but it doesn't happen at the same time as these calls to googleusercontent.com.
Any insight on this would be most welcome.

OK I think I figured it out. My web page makes a call to my node.js app running on Cloud 9... I think that the mysterious nnn.n.nnn.nn.bc.googleusercontent.com must just be where the node app is being hosted. When I call this page from my production app (where the node app is running on heroku) I get a call to a different yet similarly mysterious-looking address: xxxxxxx.eu-west-1.compute.amazonaws.com... so that must be where the heroku node app is hosted.

Related

Android use of mobile data when in background

I have developed a hybrid app running on Android, that successfully monitors the users location and displays it to the user as a moving icon on a map. This part of the app is all written in javascript and works inside a webview. The webview also communicates with my remote server to share the user's location with other users of the same app.
Up until Android Nougat this all works even when the app is backgrounded for several days. When the user returns to the app they can see where they have been with timestamps at each point. And all the other app users can see where everyone is, even if they are no actively using the app.
From Android Oreo onwards, I had to move the location tracking to a background service to get it to continue in the background and I have tested this to be still working fine even with the app in the background for a long period. Returning to the app, the user can still see where they have been. However the remote communications to the server, on Android Oreo and later, cease after approximately 2 minutes in the background.
Please could someone explain why this is, and what I could (if anything) do about it?
What is the restriction that I am running into and where is it documented on Android developer? I have set the app as not to be limited in settings/network/data saver and this makes no difference.
Would it make a difference if I replaced the webview XMLHttpRequest with similar code in background service, using volley or something similar?
All help very much appreciated.
Although I have not discovered what restriction I am running foul of, I have found that by moving the http request from the web view to the background service using volley, the server continues to be updated whether or not the application is in the foreground.
Only tested so far on Android 8,9 and 10 in the emulator. Testing soon on a real device

Android app automatically casting without user interaction (CastCompanionLibrary)

I have an Android app using the CastCompanionLibrary v2.9.1, modified to use play-services-cast:10.0.1 (just a simple change to the gradle dependencies).
Short version: The app is attempting to automatically connect to the ChromeCast device, without user interaction.
Long version:
Since updating the CCL library to use play services 10.0.1, I've had several users mention that the app is automatically connecting/casting to ChromeCast without user interaction.
Some users have said they're not using the app, then they connect to WiFi, and the app automatically attempts to cast. Others have said they are using the app, they don't press the ChromeCast button, and the app begins casting.
--
I'm having trouble figuring out where to look for potential changes to the ChromeCast APIs which might explain what's going on. I'm also not sure whether this issue is only occurring for my app, or for many other ChromeCast enabled apps. Lastly, I'm not able to reproduce this issue on my own ChromeCast device.
Any help would be appreciated.
I had not seen or heard this before, so here are some pointers for you to do further investigation to see what can be the cause. CCL has a (sticky) service called ReconnectionService that is responsible to perform reconnection attempts when you lose wifi and later gain it back. The wifi scenario you had mentioned resembles this so I would suggest to start from there. In order to only reconnect when it makes sense, it gets the time length of the content that is playing and only makes such attempts for that period of time; i.e. if you start playing a content that is for 1 hr and then you leave your phone on the table and pick it up after 2 hrs, it notices that the last movie before it fell sleep was for 1 hr so it won't make any attempt to reconnect (see handleTermination() in that same class). For live-stream that doesn't have a clear content duration, CCL uses a default of 2hrs but allows apps to modify that by calling VideoCastManager.setLiveStreamDuration(duration_in_seconds) method. Finally, the whole reconnection relies on a few factors: it saves the route-id of the last connection, along with the session ID. So if needed, you can clear any of these and then it won't try to reconnect for that particular session (in case you want to keep reconnection for some and disable on some other). Hope these help to troubleshoot the issue.
So it turns out there's a bug in Android Support Library 25.1.0 which was causing this issue.
https://code.google.com/p/google-cast-sdk/issues/detail?id=1105
Which is now marked as 'fixed internally'.
Also related:
https://code.google.com/p/android/issues/detail?id=232326

Webapps in Android: Get new content without website reload

I have an android app which is a wrapper around my mobile site. We have a site that changes everyday, and I’d like to have a method by which I can notify the user that there’s new content to be had, or just reload it programmatically.
This obviously happens when the app relaunches, but sometimes users will keep the app in sleep mode and re-open it the next day and they see a stale version of the website. Is there any way around without going native? One method I thought off was using a push notification to reload the app (i.e. use GCM to tell the app to reload the page) except I don’t want to push a new version as this would require permission changes and that would break auto-updating. I though of using socket.io for the task as I'm already using it in my app but I don’t think it'll work if the app is the background (will it? I’m an android newbie)
Thanks for any help!
When the application returns from sleep - onResume() of the activity life cycle may be invoked. If you reload the webview on this listener, that should resolve it.
Unless i am missing something very significant, this simple solution might work.

Developing an Android Client Server app

I am developing an app as follows:
Android APP (As a client)..it will send data to a Server (Java application running on a PC).
I implemented this using socket programming and it is working. I have following issues:
When I click the send button on my app the APP UI freezes for ~7 seconds. It is able to ping and connect to server but during this time frame the UI freezes and if I click any other button on the app I get a message app is stuck (but the app comes back ok after ~ 7 seconds). What is the best way to resolve it.
Once data (strings) is received on the PC, I want to show it in the form of List Box UI so that user can select/double click on the specific string and a message box is open showing that that particular string is selected. What is the best way to develop this UI and how can it be invoked directly as soon as server receives the data from Client (android app) and this UI should show up.
Please let me know. All help is appreciated.
Place all your network-related code into a separate thread, or (easier) and AsyncTask. Otherwise, you would block the UI, as you have noticed, and the app would actually crash on newer Android versions (ICS and JB).
If you search SO and the interwebs, you will find plenty of examples.

Can i call an android application's method remotely?

I am developing an android application. What i want is to call a method present in that android application remotely from a desktop like from a "servlet" or an application.
How can this be done?? For example i want to call a method which i have already written in the app which calls a particular number. How can i invoke this method remotely?? please help.
PS - It is kind of urgent.
It will be hard to communicate from your desktop to your handheld. But you can poll a server from your handheld.
Write an app that every n seconds (the frequency you require) polls e.g. a web page on your server. When the web site's content is "noop", the app does nothing and keeps on polling. If the web site's content is "doit", the app dials the number you want.
So, when you change the content of this web page either manually or programmatically you can "remote-control" your hand held.
This is just an example, it must not be HTTP, neither NOOP and DOIT, just anything you like. Let the server return the phone number which you want dialled for instance.
Well, sounds like you want your app to be waiting for push notifications. I think this question is exactly what you need to look at.

Categories

Resources