Android: Action Dialog / Dialog disappears unexpectedly

I have an application with TabActivity in which I show a dialog every time I get a callback from my engine (C code NDK). I am sure that the dialog is displayed when the application is in a resume state.

After receiving the callback from the engine, I run the NetworkDownDialog operation, but this causes the dialog to remain for a second and then disappear. The same thing happens if I use Dialog or AlertDialog . The strangest thing is that extinction seems random (not always).

This is an S3 device. What's happening?

Edit 05/23/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------- 

Action 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 dialogue fading? Is it possible that memory corruption on my own level C code is causing this problem? Am I doing something wrong on the interface side? I'm completely stuck ...

Edit in 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 deleted my tabactivity.Will can this cause the dialogue to be deleted?

+6
source share
6 answers

Well, the problem was in the c code, some kind of file descriptor fd-corrupt caused this problem. If the problem was solved at the c-level, the problem was not visible. However, it’s rather strange.

0
source
  • Make sure that you display a dialog with the application context.
  • Make sure there are no two events and click the same part of the .ie code when you are about to display the dialog, another event from the c-code to display the dialog.
  • Make sure your application has enough memory to run smoothly.
+5
source

The error you get is due to the screen not being ready to display anything while you are calling dialog.show() .

Another (possible) solution for you is to use the system dialog, as in this example:

 AlertDialog dialog = new AlertDialog.Builder(context) .setMessage(text) .setPositiveButton(R.string.ok, null) .setCancelable(true) .create(); dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); 
+3
source

After looking at the code, I recommend removing finish() in BroadcastReceiver and starting your program (for testing purposes). The problem you see may occur because your Activity starts and ends almost simultaneously.

+2
source

I think the problem is that the surface is not blocked. Here are some solutions I found in SO.

I hope they help.

android-canvas-locking and android-draw-on-camera-preview

+1
source

When I saw a channel (channel ~ Consumer closed input channel) that was followed by an error, I found that it indicates that the application is closing either by design or by an exception raised elsewhere. My guess would be that you either quit your activity or encounter an exception at the same time that a dialog is displayed, as a result of which your application starts to exit. In addition, I would add more magazine to any place that you call a department, to make sure you don’t accidentally end when you show the dialogue.

+1
source

Source: https://habr.com/ru/post/945065/


All Articles