This is a general query that I have because I have seen contrasting posts about the ways people have implemented it.
My use case is that I want my Android device to connect to iBeacon whenever it is in range, and start a particular app.
How do I go about it? I am not looking for code, in particular, a general direction of how to go about it would be good.
Here's what you can do:
You can program an app to auto-launch itself when a beacon is detected. If this app is already installed on an Android device, it can send a notification or simply appear when the beacon is seen. The free and open source Android Beacon Library has tools that let you do this. See here
Here's what you cannot do:
If you do not have a custom app installed on a phone, then you can not make the phone do anything to respond to a beacon. Once upon a time, it was possible on many phones with Google Play Services to make a beacon detection prompt a user to install your app. Google, however, discontinued this feature of their Nearby service in December 2018.
Related
My goal is to write an application for Android (>= 9.0) which basically offers a device-owner-style control like Google's "Android Device Policy".
The following criteria have to be met:
Zero dependency on Google servers or any other 3rd party infrastructure like existing EMM solutions (MobileIron et cetera)
The user should not be able to remove or disable the app
Provisioning methods: QR-Code, NFC, URL, ADB, actually any "local" way ...
Has to work with stock androids on regular consumer devices
In short: I'd like to write an unremovable device manager (including a web-based management UI), put it on a device I own, give that device to someone else, and being able to fully control the device remotely.
Is such a project even possible with the current situation of Android?
No.
Has to work with stock androids on regular consumer devices
Mostly, this is your biggest hurdle to overcome.
What you are asking for is the description of a very powerful MalWare. An app that ca run on any version of Android, that can't be uninstalled, but can do what it wants to "fully control the device".
If you move away from the idea of "stock android on regular consumer device", towards a suite of devices you have some say in distributing:
Here is a list of Google Partners who offer an EMM solution: https://androidenterprisepartners.withgoogle.com/emm/
Here is Samsungs effort at device control:
https://www.samsungknox.com/en
Here is Googles device management:
https://developers.google.com/android/management
You could write your own ROM of Android and be able to control the things you want, but that would require .. building a ROM aka a whole phone OS forked from AOSP.
The user should not be able to remove or disable the app
This is only possible if you have a system app.
Or something extreme (which with any extreme, is always possible to have problems), like having two apps, and they monitor each other for uninstall, and programatically reinstall (vs 1 app that can't do much when it is being uninstalled).
According to the Android Wear 2.0 guide, Android Wear 2 apps will be installed separately, one from the Play Store on the phone and one from the Play Store on the watch, unlike Android Wear 1.x apps which are packaged together
So guidelines suggest that app should notify user if companion application is required, but not installed on the connected device.
However, not all watches will get 2.0 upgrade and some will stay at 1.x. Those watches install apps companion automatically and if one is missing, it just means app takes a while to install through Bluetooth connection. Displaying "install companion app" notification would be meaningless on these watches as there is nothing user can do to speed up the process (there is on Play Store on older watches).
Now, the issue is that I can't find a way to display warning if connected 2.x watch does not have the app and at the same time not displaying the warning if connected watch is running 1.x.
Is there a good way to distinguish between the two different connected Android Wear versions?
There's not a good way to do this right now. It's been discussed a couple of times on the Wear developers G+ community, and the best we came up with is:
Go ahead and send the RemoteIntent to open the Play store.
Attach a RemoteIntent.ResultReceiver when you do so.
If the watch is running Wear 1.x, this will return with a resultCode of RESULT_FAILED, and you can show your user a message accordingly.
This is obviously not ideal; it involves a useless step (trying to open the Play store) for 1.x users, and there's also no way to distinguish any other possible failure modes. But as of today, it's the best we have.
Discussions:
https://plus.google.com/+SterlingUdell/posts/XJZ8mAsaZ8B
https://plus.google.com/u/0/+SterlingUdell/posts/WWBVxjcD7vT
I have a situation where I want my users to install my app for which I am using beacons. So the phone should detect the presence of app without an app, I have found a link which says it is possible in iOS because google has build beacon detector in chrome app but is there a way by which it works for android as well?
Any direction given will be highly appreciate.
The Google Chrome app has support for detecting Eddystone-URL beacon frames on both iOS and Android. I am the one who wrote the "How To Push Beacon Messages Without an App" post you link to in your question. At the time that post was written, Google had only released the functionality for the Chrome app for iOS. Since then they have released similar functionality for Chrome for Android.
The details of how the user opts-in to beacon notifications on Chrome is a bit different for Android.
In addition to Chrome support for Eddystone-URL, Android also supports beacon notifications through its Google Nearby service as part of Google Play Services, if they are installed on the phone. (On most US and European phones Google Play Services is installed. On most Chinese phones it is not.) Using this system, you must first register the beacons with Google (it works with iBeacon, Eddystone frames, and AltBeacon), but the notification to be displayed must be configured on Google servers. You can read more about this here.
I'm researching ways on how to do activity recognition using an android smartwatch. Currently, I'm focusing on detecting whether the user is walking or standing still. My first idea was to use the built in step counter, but then I came across the Android Activity Recognition API (I'm relatively new to Android^^) which seems to be used in mobile apps only.
I'm now stucking at answering the following questions:
Is the current API already making use of a connected wearable device?
(e.g. automatically accessing built-in wearable sensors)
Is there a seperate API available for Android Wear?
Is there any other best practice on how to use wearables for activity recognition? (especially walking and standing still)
During my research I've already tried the following things:
Reading through the Android Activity Recognition Guide
Reading through this article about Google's Activity Recognition API
Implementing a simple Android Wear App which uses the current Activity Recognition API. I tested the app on my LG G Watch without success. It seems like I can connect to the ActivityRecognitionClient but I never receive any activity updates. I tried the same code on my Nexus 5 - everything works fine.
Reading through this post about Google Play Services. Here the author is like "...We like the Activity Recognition API for Android Wear, as we’ve always thought the location tracking technology was a great backbone for this type of functionality...". So according to this, there is a seperate API, right?
I would be very thankful for any helpful information from you guys. In my opinion, a cool thing (see first question) would be to automatically detect a connected wearable device and use its sensors for enhancing the accurancy when the mobile phone is unsure about the current user's activity.
You ask
Is the current API already making use of a connected wearable device?
(e.g. automatically accessing built-in wearable sensors)
No, and this would not make sense would it? The wearable and handheld device is not always carried at the same time; the watch can be moving, and the handheld still. (vice versa) I am not sure what the value of a combined measurement would be.
Is there a seperate API available for Android Wear?
Yes. google provide a different Google Play Services library or wearables you see this in the compile dependencies;
compile'com.google.android.gms:play-services-wearable:6.5.87'
vs
compile 'com.google.android.gms:play-services:6.5.87'
So, when you tested the API in your first Moto360 app, you actually imported the play services libraries meant for handhelds instead of the wearable version. The constant "ActivityRecognition.API" is not included in the wearable version of the client API.
Is there any other best practice on how to use wearables for activity
recognition? (especially walking and standing still)
One way would be to use the raw accelerometer data to detect motion. It is fairly easy to detect that the device is not moving at all, to detect anything else is not trivial.
You could push sensor data from the wearable to the handheld for processing there if you like. Ping me if you'd like some code showing just that. I don't want to post it since it is not relevant to the question.
My guess is that Google will include this API on the handheld device in the future. Spending a lot of time "rolling your own" might be a risk...
Unfortunately, the activity recognition API is not yet implemented on Wear devices. When I tested a simple ActivityRecognitionClient API example program on my Motorola Moto 360 (with "4.4W 2"), I got a message indicating that on the logcat stream.
I have a problem when i am trying to use my chromecast device.
Currently I have an app for Android , one for iOS
and these 2 apps from github.
https://github.com/googlecast/MediaRouter-Cast-Button-android
https://github.com/googlecast/CastVideos-android
All of them have a common problem. They sometimes cannot accuratelly tell if a chromecast device is connected or disconnected.Taking around a minute before they find it out themselfs.While an application like Youtube , discovers if it is connected or not, instantly.
EDIT #1 START:
While using the application "Cast Videos" for android from GitHub the following thing happens.
I hold the android device in my hand (Samsung Galaxy S2).
I know chromecast is on because I can see it on my monitor.
I start the application "Cast Videos".
The Chromecast icon does not appear, even if the chromecast device is on.
EDIT #1 END;
I have tried using the app_id from my own receiver application , and the default receiver app_id.
I have found a way to trick them into finding the device. By launching the youtube application on an Android or iOS device , connect to the chromecast device , then disconnect.
When I return to on off the apps I have mentioned at the start of the question , they can detect it now , and connect to it.
The two applications from github are not modified , and use the most up to date support libraries (appcompat, mediarouter, CCL).
The applications are now being currently build on a Mac (if that matters). I don't think it will be of any difference if they were built on Windows or something else.
EDIT #2:
I am starting to suspect that actually the wifi router in the building im programming may cause these connection problems. Because when I send the app to other people they don't have the same problem.
EDIT #3:
Good news :D.
The latest update on the castcompanionlibrary made chromecast detection much more reliable and the sample now detects preciselly every time if it is connected or not.