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.
Related
I'm having a problem where an app I'm developing is working on mobile devices (tested on 4 different devices), but crashing when I try to test it on my tablet. The tablet I'm using is a Tesco Hudl 2, which, although being a good quality low cost device, lacks adb drivers and so you can't debug apps through USB and get the Logcat data. The app was developed using Android Studio.
With other apps I have developed, I have just set up ACRA in the project so I can still get debug information from a crash. This time however, the app is crashing without any information from ACRA and so I'm not quite sure what is going wrong. I'm pretty sure I've set up ACRA correctly given that I've used it in several projects before and see nothing wrong this time. Can it be that whatever is going wrong is happening too early for ACRA to catch?
I have pulled out all the code from the activity so the only thing that happens in code is that ACRA gets initialized in the derived Application class (note that the crash exists without ACRA). The app also uses Google maps and a provider for search suggestions. If there is any code anyone wants to see just ask, but I'm unsure what exactly to post up since everything else was stripped out. So, does anyone have any idea on what I can do to solve this, or what tools I can use to catch whatever sort of errors happen so early in the apps lifecycle?
Thanks
Update with strange behaviour... Downloaded Crashlytics and it also did not catch the crash. I copied the project and removed every .java file except the Application, Activity and provider. The provider functions were empty (save for the return value of 0/false/null/whatever), the application class just initialized Crashlyitcs and the Activity class was empty. This then worked, I was even able to add in a lot of the code and get the google map to load.
Now if I do the same in my main project, except don't delete the .java files, the crash still happens. The classes in these files are not used so I have no idea how they can be causing the crash. Otherwise all the xml, gradle, resources are identical (except the package and app name). Very confusing...
Consider using one of the apps to view logcat on the device:
https://play.google.com/store/apps/details?id=com.nolanlawson.logcat
https://play.google.com/store/apps/details?id=org.jtb.alogcat
Also try using Crashlytics. Maybe it will catch your crash?
But yeah, it's possible to have a crash before any crash reporter (ACRA or Crashlytics) will have a chance to catch it.
And one more note, maybe there is a way to enabled ADB over WiFi.
Normally you would need to enable it via adb but maybe in case of this cheap and strange tablet, there is an option for that enabled in the ROM?
Ok! So it's 1am and I decided to have one final attempt to fix, which I think I did. In my manifest, I had things like
<activity
android:name=".MyActivity"
...
for example, and while this worked fine on the mobiles, for some reason the Hudl required the complete package name, i.e. com.mypackage.MyActivity. Not sure why this is the case but it appears to have fixed the problem.
My application is probably running out of memory or it is some issue with that. I have exception handling on application so if i got exception It is send to my email, it is good for debug, but recently I have got a strange issue, when I put my application to background and start 2-3 other application for example Gallery when i want to reopen my application instance it shows me Application stops work and no exception is send to me, so it is hard to solve, can you please help me to solve my issue, or handle that memory issue and restart the whole app instead of showing that the application has stopped worked.
thank you very much. It will also help if you show me how to simulate that memory issue when the application is in debug mode.
my manifest:
<application
android:name=".utils.JLApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="JustLook"
android:largeHeap="true"
android:noHistory="true"
android:launchMode = "singleTop"
android:theme="#style/JLTheme">
I also think that maybe my application is correct but some of the libraries or something has stopped to work and that throws my application. But I am not sure of that. I also noticed that it happened frequently when i implemented google api connection and fuse location listener, but i am also not sure if it causes this kind of problem, maybe the memory issue is more likely bug here. But I dont know how to find it or solve it because it does not throws exception.
I dont think that your problem is memory related.
According to how you describe your problem, i'm assuming that your crash is caused by a NullPointerException.
As MarkySmarky described, Android kills background applikations to gather memory space.
So please have a look at your MainActivitys onResume or onStart. There must be some handlers, adapters, etc. that are null when you are resuming your app.
In addition, i would suggest to add Crashlytics to your project. It tracks your crashes in detail. If have a crash report regarding your problem, please post it here.
I must say that the behaviour that you've described sounds perfectly normal besides that crash thing ;)
Android kills background applications when it needs to free up memory for other apps. The crash you're having MUST somehow be related to your code running in onCreate() of JLApplication. The best way to debug or find this bug is either start your application in debug mode or spread logs all around.
You can also take a look at Debug.waitForDebugger().
btw you should have a really good reason for having the following in you application tag - "largeHeap"
* -- 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!
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.
I have an application that uses a native library (.so).
In the new version of the application I made changes in the lib. The problem is that after upgrading the application it looks like the new library is not loaded.
If I force stop the application and then I restarted it everything works fine.
In some cases just waiting for a while (for example 20 mins) fixes the problem.
Did anyone experience this issue?
Is there a way to fix it?
EDIT
I have also tried to call
System.loadLibrary("mylib.so");
in the onReceive of the OnUpgradeReceiver that is the broadcast receiver that is registered to be called when the application is upgraded
It did not help
EDIT2
I think this issue has to do with the fact that the lib uses the audio engine. The reason iwhy I think so is that I tried to change the name of the lib and it did not help either
Ok never mind I think the issue is just in my lib. I need to find where but I checked that the application is properly closed after the upgrading.