I have an application with TabActivity
in which I am displaying a dialog each time I get a callback from my engine (NDK C code). I make sure dialog is displayed when app is in resume state.
Upon receiving the callback from the engine, I start the NetworkDownDialog
activity, but this causes the dialog to stay for a second and then disappear. The same thing happens if I use Dialog
or AlertDialog
. Most strangely, the disappearance seems random (doesn't always happen).
This is an S3 device. What's going on?
Edit on 23/05/2013
Network Down Dialog Code
public class NetworkDownDialog extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.network_down);
Logger.d("NetworkDownDialog", "----------onCreate-----------");
registerReceiver(mNetworkDownReceiver, new IntentFilter("NetworkDown"));
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(mNetworkDownReceiver);
Logger.d("NetworkDownDialog", "------onDestroy-------");
}
@Override
protected void onResume() {
super.onResume();
Logger.d("NetworkDownDialog", "------onResume-------");
}
@Override
protected void onRestart() {
super.onRestart();
Logger.d("NetworkDownDialog", "------onRestart-------");
}
@Override
protected void onStart() {
super.onStart();
Logger.d("NetworkDownDialog", "------onStart-------");
}
@Override
protected void onStop() {
super.onStop();
Logger.d("NetworkDownDialog", "------onStop-------");
}
@Override
public void onBackPressed() {
Logger.d("NetworkDownDialog", "------onBackPressed Do nothing-------");
}
private BroadcastReceiver mNetworkDownReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
finish();
}
};
}
In the logs, this is what I see:
05-15 20:48:02.981 D/NetworkDownDialog( 1050): ------onCreate-------
05-15 20:48:02.981 D/alsa_ucm( 202): Setting mixer control: RX5 MIX1 INP2, value: RX2
05-15 20:48:02.991 D/alsa_ucm( 202): Setting mixer control: RX6 DSM MUX, value: DSM_INV
05-15 20:48:02.991 D/alsa_ucm( 202): Setting mixer control: LINEOUT2 Volume, value: 100
05-15 20:48:02.991 D/alsa_ucm( 202): Setting mixer control: LINEOUT4 Volume, value: 100
05-15 20:48:02.991 D/NetworkDownDialog( 1050): ------onStart-------
05-15 20:48:02.991 D/alsa_ucm( 202): Setting mixer control: RX5 Digital Volume, value: 65
05-15 20:48:02.991 D/NetworkDownDialog( 1050): ------onResume-------
Activity Dialog displayed
**05-15 20:48:05.073 W/InputDispatcher( 716): channel ~ Consumer closed input channel or an error occurred. events=0x9
05-15 20:48:05.073 E/InputDispatcher( 716): channel ~ Channel is unrecoverably broken and will be disposed!**
05-15 20:48:05.073 W/InputDispatcher( 716): Attempted to unregister already unregistered input channel
05-15 20:48:05.083 I/SurfaceFlinger( 195): id=2033 Removed idx=5 MapSz=4
05-15 20:48:05.083 D/KeyguardViewMediator( 716): setHidden false
05-15 20:48:05.103 I/Adreno200-EGLSUB( 195): <CreateImage:897>: Android Image
05-15 20:48:05.103 I/Adreno200-EGLSUB( 195): <GetImageAttributes:1106>: RGBA_8888
**05-15 20:48:05.103 E/BufferQueue( 195): [mypackage.NetworkDownDialog] dequeueBuffer: SurfaceTexture has been abandoned!
05-15 20:48:05.103 E/SurfaceTextureClient( 1050): dequeueBuffer failed (No such device**)
05-15 20:48:05.103 D/PhoneStatusBar( 894): addNotification score=0
05-15 20:48:05.123 E/ViewRootImpl( 1050): Could not lock surface
05-15 20:48:05.123 E/ViewRootImpl( 1050): java.lang.IllegalArgumentException
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.view.Surface.lockCanvasNative(Native Method)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.view.Surface.lockCanvas(Surface.java:88)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2314)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2277)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2145)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1956)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1110)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4472)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.view.Choreographer.doFrame(Choreographer.java:525)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.os.Handler.handleCallback(Handler.java:615)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.os.Handler.dispatchMessage(Handler.java:92)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.os.Looper.loop(Looper.java:137)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at android.app.ActivityThread.main(ActivityThread.java:4918)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at java.lang.reflect.Method.invokeNative(Native Method)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at java.lang.reflect.Method.invoke(Method.java:511)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
05-15 20:48:05.123 E/ViewRootImpl( 1050): at dalvik.system.NativeStart.main(Native Method)
In this case, the ActivityDialog
disappeared after the above.
Why is my dialog disappearing? Is it possible that memory corruption at my C level native code is causing this problem? Am I doing something wrong on the UI side? I'm totally stuck...
Edit on 24 -05 -2013
05-24 19:49:00.025 I/SurfaceFlinger( 1901): id=2147 Removed NainTabActivity idx=3 MapSz=4
05-24 19:49:00.025 I/SurfaceFlinger( 1901): id=2147 Removed NainTabActivity idx=-2 MapSz=4
SurfaceFlinger removed my tabactivity.Will this can cause dialog remove?
After seeing your code, I would recommend that you remove finish()
in your BroadcastReceiver
and run your program (for testing purposes). The problem you're seeing may happen due to having your Activity
starting and ending almost at the same time.
I think the problem is due to the surface not being locked. Here are some solution which I found at SO.
Hope they help.
android-canvas-locking and android-draw-on-camera-preview
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With