Reputation: 1187
I'm working with a test app for communication between an android phone (Galaxy SIII, android 4.1.2) and arduino using MicroBridge (via adb). The android app does all the work using ndk with a java side just to get things started and display some data.
Things work fine for 30s-60s but then my app suddenly closes and I can't figure out why. Looking at logcat output, it's not a crash; things are closing in the normal fashion. Android seems to just be telling my app to close. The only thing I can find is this sequence of logcat lines always right before my app is closed.
D/MTPRx (29019): DRIVER_TIME_OUT 60s lapsed
D/MTPRx (29019): still no open session command from host, so toast
E/MTPRx (29019): started activity for popup
I'm not sure exactly why that is related, but I think there's a connection somewhere. As implied by the first line, if I wait to start my app until a couple minutes after plugging in the USB cable, it seems to work fine.
Does anyone know what is going on here and, more importantly, how to keep my app from getting closed?
UPDATE: Just a bit more information from further testing:
Upvotes: 4
Views: 373
Reputation:
check if libc throws any exception , this could be a crash in you NDK code that closes the app
Upvotes: 1
Reputation: 71
I've hit this problem recently and thought I'd share what I found, since this is the only place that shows up when searching for this problem in Google.
My setup is: Samsung Galaxy Camera with Android 4.1.2 connected to an IOIO board. My problem was that 60s after connecting the device to the IOIO board my foreground activity was paused and then immediately resumed. Adb log contained the same lines from MTPRx as in the original question. This was a problem for me because my activity was recording a video and I stopped the recording in the onPause handler.
It turns out that MRPRx is a daemon that handles the MTP protocol. Apparently the IOIO board does not make any attempt to talk MTP and this throws the daemon off. Which in turn causes the current foreground activity to be paused.
I haven't found a way to prevent this from happening, but since in modern versions of Android the paused state of an activity is not killable, I decided to work it around by moving everything from the onPause handler to the onStop. This worked fine for me, but may not be suitable in every case.
These findings do not completely explain all symptoms that the TS described, so maybe there is something else going on.
Upvotes: 0