关闭Android应用程序,它的运行首页preSS功能 [英] Close android app and it's running features on Home press

查看:133
本文介绍了关闭Android应用程序,它的运行首页preSS功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道你怎么说,你不应该强迫你的应用程序关闭,但我还挺需要它。 关键是,我的应用程序有震动和声音(媒体播放器)在同一时间。因此,当用户presses家,就应该停止这两个和关闭应用程序下来。现在没有任何反应,当我preSS首页 - 实际上它还挺冻结(但声音和振动的推移) - 直到应用程序崩溃。

 如果(mpButtonClick.isPlaying())
                    {mpButtonClick.pause();
                    mpButtonClick.seekTo(0);

                    vibr.cancel();
                    }

                    其他
                    {

                    mpButtonClick.start();
                    INT长度= mpButtonClick.getDuration();
                    vibr.vibrate(长);

                    }
 

我也有一个的onDestroy和onBack pressed(它们是相似的):

  mpButtonClick.stop();
            vibr.cancel();
        super.onDestroy();
        System.runFinalizersOnExit(真正的);

                System.exit(0);
 

onBack pressed完美的作品。但家 - 按钮崩溃。 任何想法?

在此先感谢。

解决方案
  

我知道你怎么说,你不应该强迫你的应用程序关闭,但我还挺需要它。

没有,你不知道。

  

因此​​,当用户presses家,就应该停止这两个

停止媒体播放和振动的onPause()的onStop()

  

但家 - 按钮崩溃。任何想法?

使用亚行logcat ,DDMS或DDMS透视图在Eclipse检查LogCat中,看看与你的崩溃相关联的堆栈跟踪。考虑开辟了新的问题与堆栈跟踪的详细信息,以及相关的源$ C ​​$ C,这样的人可以帮你这个崩溃。

I know all of you say that you shouldn't force your app to close, but I kinda need it. The thing is, my app has vibrate and sound (mediaplayer) at the same time. So when the user presses "Home", it should stop those two and "close the app down". Right now NOTHING happens when I press Home - actually it kinda freezes (but sound and vibrate goes on) - until the app crashes.

                        if (mpButtonClick.isPlaying())
                    {mpButtonClick.pause();
                    mpButtonClick.seekTo(0);

                    vibr.cancel();
                    }

                    else
                    {

                    mpButtonClick.start();
                    int length = mpButtonClick.getDuration();
                    vibr.vibrate(length);

                    }

I also have a onDestroy and onBackPressed (they're similar):

                    mpButtonClick.stop();
            vibr.cancel();
        super.onDestroy();
        System.runFinalizersOnExit(true);

                System.exit(0);

onBackPressed works perfectly. But "Home"-button crashes. Any ideas?

Thanks in advance.

解决方案

I know all of you say that you shouldn't force your app to close, but I kinda need it.

No, you do not.

So when the user presses "Home", it should stop those two

Stop the media playback and vibration in onPause() or onStop().

But "Home"-button crashes. Any ideas?

Use adb logcat, DDMS, or the DDMS perspective in Eclipse to examine LogCat and look at the stack trace associated with your crash. Consider opening up a fresh question with details of the stack trace, along with the associated source code, so people can help you with this crash.

这篇关于关闭Android应用程序,它的运行首页preSS功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆