在黑莓异常终止之后不听PhoneListener [英] Not Listen PhoneListener after Abnormal Termination in Blackberry

查看:191
本文介绍了在黑莓异常终止之后不听PhoneListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的应用程序,跟踪呼入/呼出电话和放大器;节省话费记录到数据库中。
昨天我看到在该申请通过操作系统和放大器终止的情形;一个警告信息弹出的(错误:应用程序没有响应)。后应用由操作系统终止。应用程序是不能够再次聆听未来/呼出。
我认为,申请手机监听器是通过非正常应用程序终止注销。
OS调用 System.Exit(0)应用程序终止

I am working on application that tracks the InComing/Outgoing calls & save calls records into Database. Yesterday I seen a scenario In which application is terminated by OS & a warning message pops Up (Error: Application is not responding). After application is terminated by OS. Application is not able to listen In Coming/Outgoing calls again. I think, Application Phone Listener is unregistered by abnormal application termination. Os calls System.Exit(0) for application termination

如果我按照这个办法: -

If I follow this approach :-

public static void main(String[] args) 
{
    /** 
     * Registering the phone Listener. 
     * */
    Phone.addPhoneListener( new ConcretePhoneListener() );

   new SampleUIApp().enterEventDispatcher();
   }

在此情况下,在应用程序每次启动时,手机监听器被注册。
和应用程序的(电话监听器)注册多次。用于在单个输入/输出呼叫我越来越多发性次

In this case every time at the application start up , phone listener is registered. And Application's (Phone Listener) registered multiple times. Means for a single In/Out Call I am getting multipule times

void callConnected( int aCallId ) 
callDisconnected( int aCallId ) 

有关sourt了这个问题,我使用的运行时存储管理系统。
 对于这个我使用下面的方法: -

for sourt out this issue , I am using RunTime Store Management System. For this I am using Following approach :-

private static void registeringPhoneListener() 
{
    RuntimeStore mRuntimeStore = RuntimeStore.getRuntimeStore();
    final long GUID = 0xba9e3b33ac5fe37eL;

    String msPhoneListenerString = null;

    if(mRuntimeStore.get(GUID) != null)
    {
        Log.debug(  "PhoneListener is Already Implemented ## ");
    }
    else
    {
        Phone.addPhoneListener( new ConcretePhoneListener() );
        mRuntimeStore.put(GUID, "PhoneListener");   

          Log.debug("PhoneListener Implemented First Time ## " );           
    }
}

这种做法是工作的罚款,直到我得到OS异常终止,
因为RuntimeStoreManagemnet不为空,但应用手机监听器是Derigester。

this Approach is working fine until I get abnormal termination by OS, Because RuntimeStoreManagemnet is not null but Application Phone-listener is Derigester.

请帮我出这一点。

推荐答案

有更回事,这里比你对我们,所以我不相信这是正确的答案。我深信的是,你需要改变你的code,使这项工作正常给你。

There is more going on here than you have shown us, so I am not convinced that this is the correct answer. What I am confident on is that you need to change your code to make this work properly for you.

我怀疑你滥用监听器处理。

I suspect you are misusing the listener processing.

通常听众,他们正在侦听的应用程序的环境中运行。所以其实你的听众是根据电话应用程序的控制运行。你不想打破这个(因为它似乎你正在做的),在你的听众code。所以,你应该让你的听众code紧(高效和牢不可破的),你可能可以。在这种情况下,从内存,监听器与事件线程中运行,因此除了确保你的code是紧的,你不应该做任何阻塞操作 - 并且记得读一个数据库可以算作一个阻塞操作。

Normally listeners run in the context of the application that they are listening on. So in fact your listener is running under control of the Phone application. You do not want to break this (as it appears you are doing) in your listener code. So you should make your listener code as tight (efficient and unbreakable) as you possibly can. In this case, from memory, the listener runs with the Event Thread, so in addition to making sure your code is tight, you shouldn't do any blocking operations - and remember reading a database could count as a blocking operation.

一般建议,以确保听众做尽可能少的 - 最好的建议是,他们启动一个全球性事件和重处理您的应用程序处理

The general recommendation is to make sure listeners do as little as possible - the best recommendation is that they kick off a global event and the heavy processing is handled in your application.

下面是关于全球活动的文章:

Here is an article about Global Events:

<一个href=\"http://supportforums.blackberry.com/t5/Java-Development/Global-Events-and-Global-Event-Listeners/ta-p/444814\" rel=\"nofollow\">http://supportforums.blackberry.com/t5/Java-Development/Global-Events-and-Global-Event-Listeners/ta-p/444814

在讨论理论,发生了什么吗?

Having discussed the theory, what is happening here?

在这种情况下,我怀疑你的监听器被阻塞和你正在服用了电话应用程序。我是pretty确保手机应用程序获取由系统重新启动(有什么用,而不电话应用程序!手机),所以你可能不会注意到这一点。但是,在重新启动Phone应用程序时,它并没有监听器 - 所以你停止的通知。

In this case I suspect your listener is blocking and you are taking down the Phone application. I am pretty sure the Phone application gets restarted by the system (what use is the phone without the phone application!) so you might not notice this. But when the Phone Application is restarted, it does not have your listener - and so you stop getting notifications.

所以,我认为你需要修复监听器code,以确保它停止取下来的手机应用程序。

So I think you need to fix your Listener code to make sure it stops taking down the Phone application.

我怀疑你有两个选择:


  1. 将加工用的全球盛会自己的应用程序(我
    推荐)

  2. 将阻塞操作关闭事件线程。

实施要么应该停止你的应用打破了手机应用程序,问题将得到解决。

Implementing either should stop your application breaking the Phone Application and the problem will be resolved.

这篇关于在黑莓异常终止之后不听PhoneListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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