Android:活动对话框/对话框意外消失

前端之家收集整理的这篇文章主要介绍了Android:活动对话框/对话框意外消失前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个TabActivity应用程序,每当我从我的引擎(NDK C代码)获得回调时,我都会显示一个对话框.当应用程序处于恢复状态时,我确保显示对话框.

收到引擎回调后,我启动了NetworkDownDialog活动,但这会导致对话框停留一秒然后消失.如果我使用Dialog或AlertDialog,也会发生同样的事情.最奇怪的是,失踪似乎是随机的(并不总是发生).

这是一个S3设备.这是怎么回事?

编辑于23/05/2013

网络向下对话代码

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();
        }
    };
}

在日志中,这是我看到的:

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-------

显示活动对话框

**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)

在这种情况下,ActivityDialog在上述之后消失了.

为什么我的对话框消失了?我的C级本机代码中的内存损坏是否可能导致此问题?我在UI方面做错了吗?我完全陷入困境……

编辑于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删除了我的tabactivity.这会导致对话框删除吗?

@H_301_30@

解决方法

>确保您正在显示带有应用程序上下文的对话框. >确保没有两个事件发生并触及代码的相同部分.当您要显示对话框时,c代码中的另一个事件将显示对话框. >确保您的应用程序有足够的内存来顺利运行. @H_301_30@ @H_301_30@

猜你在找的Android相关文章