Android Activity Recognition Sample Bug - android

So I downloaded the Sample App for 'Recognizing the User's Current Activity' on the android website http://developer.android.com/training/location/activity-recognition.html
The problem I'm having is that when I press the 'Start Updates' button, then the 'Stop Updates' button, and then the 'Start Updates' button again, the updates don't start again the second time.
I've searched online but couldn't find much material on the topic so yeah, I've also tried debugging and found that the onDisconnected() method call (via the ConnectionCallbacks interface) isn't being called in either of the DetectionRemover.java or DetectionRequester.java files.
If anyone knows why this is happening I'd really like to know why. From what I've gathered it doesn't seem to be anything in the sample code, and I think it might be a problem on the Google Services side.
P.S. I'm using Google Play services rev 16. along with a Samsung galaxy s2 android version 4.1.2

I noticed this same problem running the sample code on my Nexus 4 (Android 4.4.4). I found that if I commented out the following line of code in the ActivityDetectionRemover continueRemoveUpdates() method, it fixed the problem:
mCurrentIntent.cancel();
Sorry, I don't yet have a good explanation as to why canceling the PendingIntent causes this issue.
UPDATE: I also commented out the cancel in the MainActivity onStopUpdates() method:
mDetectionRequester.getRequestPendingIntent().cancel();
Which is effectively doing the same thing as the first line above.

Related

How to execute Google Play Location Samples from github

I managed to build the sub project BasicLocationSample from https://github.com/googlesamples/android-play-location. But as soon as I try to run either in Emulator or in Samsung Galaxy S 2. It immediately crash. I tried to check any reasonable clue in logcat but nothing significant to mention. I tried to set breakpoint at Main Activity's onCreate very first line. It doesn't even call it :( .
I can run ActivityRecognition and LocationAddress sample from the same sample list. So I must be missing something from BasicLocationSample. Please inform me how to run BasicLocationSample? Thanks in advance!

Android - GoogleApiClient ActivityRecognitionIntentService is never called

I need to detect user dynamics in my application. I started by using GooglePlayServicesClient which till three months ago worked perfectly, Then it stopped working on my HTC one device (although it was still working on three different devices I've checked). I know it is now replaced by GoogleApiClient, so I thought this was my problem, but it keeps not working even after changing to the new API.
The problem is that the intent given to ActivityRecognition.ActivityRecognitionApi.requestActivityUpdates is never called. I used the same implementation as : https://blacode.wordpress.com/2014/12/26/user-activity-recognition-through-new-activityrecognitionapi-in-android-activityrecognitionclient-deprecated/
(And again, this implementation works on three other devices but not on HTC one).
I did some reading online and I saw some similar issues that were solved by updating google play or activating google play location services or disable mock location on the android developers settings. Non worked for me.
Has anyone encountered the same problem or maybe has some idea what can be the cause?
If your onHandleIntent is not being triggered, make sure you have a receiver tag in your manifest (inside the application tag, but outside the activity) :
<service
android:name=".ActivityRecognitionIntentService"
android:exported="false" />
I struggled with this for several hours before finally realizing this was missing. As soon as I added it, everything worked.
Also, if you add an IntentService class through the AndroidStudio submenu for IntentService instead of just adding a plain Java class and setting it up yourself, it will automatically be registered in the manifest. New...->Service->IntentService
Eventually what solved it was resetting the device to manufacturer settings, meaning that the problem was some setting in the device , which I still have no clue to what caused it. If anyone finds an answer I'll be glad to hear about it.

Does Chromecast MediaRouteButton have a production bug?

* -- The issue is my APP ID so as not to waste anybody's time.
On the off chance this helps some other noob the real problem was I forgot to check the:
"Send serial device # to Google when checking for updates" checkbox below the fold on the Chromecast device setup application.
I also then had to reboot my Chromecast device for this to take effect.
Now Naddaf's github works fine!
Before beginning: I have no problem casting examples that use ActionBarActivity so my chromecast configuration is definitely not the issue.
In reference to:
https://github.com/googlecast/MediaRouter-Cast-Button-android
There seems to be a bug in that
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
located in: MediaRouterButtonActivity.java
NEVER receives a callback.
This was reported 4 days ago:
https://github.com/googlecast/MediaRouter-Cast-Button-android/issues/5
The long version:
I have a mature beta of my video based Android app that uses FragmentActivity and currently targets SDK 14+.
I have set up a Chromecast device for development successfully and it works with the sample apps in SDK/Extras just fine. The problem there is they all are predicated on inheriting from ActionBarActivity which is mutually exclusive/incompatible with FragmentActivity.
Every example from StackOverflow or github (only one project) that I have tried that uses android.support.v7.app.MediaRouteButton does run only the MediaRouteButton never instantiates.
When tracing I see that the following is the issue:
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
The callback is added but the Chromecast SDK never calls back to it.
Google gives an entire walkthru using the ActionBarActivity but only makes a fleeting reference to the alternative use of the MediaRouteButton.
I have now wasted 2 days already trying to wrap my head around this but guessing one's way through it sub-optimal.
Is there anybody who has a working example of using the MediaRouteButton with FragmentActivity or a link to working documentation. This is now seeming like a major oversight by the Chromecast team.
Thanks!

Many many issues, eclipse, android MediaPlayer, etc

I've recently started android programming, and I'm extremely frustrated to say the least with a lot of things that to me seem simple but are totally holding me back from making any progress. The first of which is the "my first app" hello world that I started a tutorial from http://developer.android.com/training/basics/firstapp/creating-project.html
This tutorial worked fine when I was originally looking into android a while ago. Then when I came back after learning a bunch of java this program will no longer work unless I change the target-sdk to version 10 (I found that solution after extensive searching on this site).
Then I moved on to starting tutorials by thenewboston
All of these work fine as long as I didn't use any new targetsdkversion, so I'm wondering what happened that everywhere I go looking for tutorials I can't find anything that will actually work on the current ADT(4.4W and L are what my eclipse automatically set up) and eclipse (indigo). I'll also get issues saying lint isn't working, or trouble with android SDK content loader when I'm not even doing anything.
I've also found snippets of code example on the developer website that I linked earlier that don't work when implemented either
So, am I missing something, is that just old documentation, or is something up with eclipse and ADT? I'm just so frustrated that everything wants to bug out on me when I'm just trying to follow simple introductory tutorials and I don't even know where to turn for tutorials that I can trust to work..
edit:removed code because it wasn't needed.
To not get blocked What you can do is continue to set "targetVersion as '19'" instead of setting it to 20 or so. Ensure that you've downloaded API19 through SDK Manager and create the AVDs with that targetSDK version for checking you apps.
That way you can proceed ahead with your coding and later when things get resolved by google for API20...you can always comeback to that new version. This way you can follow 'TheNewBoston' and start coding in Android.
I also recommend 'Slidenerd' tutorials over youtube as well for the beginner.
BTW, I've also selected 'Blank Activity / Empty Activity" during the project creation with API19 and been able to move ahead with my coding.
The Google Bug thread about this latest version issue can be tracked here : The google bug
As a beginning developer, I suggest you use API 19. It has been out for a while and is more stable than L or Google Wear.

Can IDEA's logcat filter automatically recognize running app?

Either I am unable to find this or IDEA still hasn't implemented the smart filter like Eclipse did long time ago.
When I am looking at logcat tab in IDEA 11, I do not see that it automatically recognizes running app and adds it under All Messages, just like Eclise does for each runnung app.
Am I missing something?
I saw that they added "Improved Filtering" feature a year ago (link), but I still haven't found a good use of it. Have you?
This feature is not available yet. I've added a new feature request, feel free to vote.

Categories

Resources