有一个以下的类
class HYPERSIP_CALLBACK
{
public final static int HYPERSIP_EVENT_CALL_IN = 0;
public final static int HYPERSIP_EVENT_ANSWER = 1;
public final static int HYPERSIP_EVENT_ISVIDEODATA = 2;
public final static int HYPERSIP_EVENT_TERMINATED = 3;
public final static int HYPERSIP_EVENT_RENDERING = 4; public void callback(int port, int event)
{
Log.e("HYPERSIP_API", "HYPERSIP_CALLBACK.callback, event = " + event);
switch(event)
{
case HYPERSIP_EVENT_RENDERING:
//will be transfer back to the JNI codes

case HYPERSIP_EVENT_TERMINATED:

break;
case HYPERSIP_EVENT_CALL_IN:
//这边会收到相信的消息,现在要通知更新UI,让主界面能调出一个新界面,这要如何实现
break;
case HYPERSIP_MESSAGE_INCOMING:
break;
}
}
}这类是独立的,会在onCreate时去调用
 HYPERSIP_CALLBACK m_callback = new HYPERSIP_CALLBACK();
HYPERSIP_API.HYPERSIP_RegisterCallback(m_callback);问题见上面的红色注明,因为以前是写C++,刚入手android,有些不太清楚,麻烦大家了。

解决方案 »

  1.   

    楼上可以说的详细些吗?
    在上面的收下的消息
    Looper looper = Looper.myLooper();//取得当前线程里的looper
                MyHandler mHandler =new MyHandler(looper)
                mHandler.removeMessages(0);
                String msgStr ="HYPERSIP_EVENT_TERMINATED";
                Message m = mHandler.obtainMessage(1, 1, 1, msgStr);
                mHandler.sendMessage(m);MyHandle类定下如下
    class MyHandler extends Handler{             
        public MyHandler(Looper looper){
               super(looper);
         }
        @Override
        public void handleMessage(Message msg) {//处理消息
         Log.e("handleMessage","handleMessage");
         }            
    }
    这个是在界面的,但是没有收到消息啊
      

  2.   

    一般我的做法是吧callback这个方法写在activity里,这个activity实现了接口
    interface someInterface {
    public void callback(int port, int event);//这个callback最终要在handler里调用
    }然后HYPERSIP_CALLBACK加一个属性譬如callbackListener,然后这个callbackListener就是相应的activity。你这种做法很早以前我也用过可以改成这样class HYPERSIP_CALLBACK
    {
        public final static int HYPERSIP_EVENT_CALL_IN            = 0;
        public final static int HYPERSIP_EVENT_ANSWER            = 1;
        public final static int HYPERSIP_EVENT_ISVIDEODATA        = 2;
        public final static int HYPERSIP_EVENT_TERMINATED        = 3;
        public final static int HYPERSIP_EVENT_RENDERING        = 4;
        private Handler handler;
        public void setHandler(Handler handler) {
            this.handler = handler;
    }    public void callback(int port, int event)
        {
            Log.e("HYPERSIP_API", "HYPERSIP_CALLBACK.callback, event = " + event);
            switch(event)
            {
            case HYPERSIP_EVENT_RENDERING:
                //will be transfer back to the JNI codes
                 
            case HYPERSIP_EVENT_TERMINATED:
                 
                break;
            case HYPERSIP_EVENT_CALL_IN:
                //<span style="color: #FF0000;">这边会收到相信的消息,现在要通知更新UI,让主界面能调出一个新界面,这要如何实现</span>
                handler.sendEmptyMessage(event);
                break;
            case HYPERSIP_MESSAGE_INCOMING:
                break;
            }
        }
    }
      

  3.   

    @Override
    public boolean handleMessage(Message msg) {
    switch(msg.what)
    {
    case 0: Log.d("ThreadId", "HandlerMessage:"
    + String.valueOf(Thread.currentThread().getId()));
    break;
    }
    return false;
    }楼上类我改成你写的那样,在activity中如上,收不到消息啊
      

  4.   


    如果在activity里做,可以给个详细的吗?
      

  5.   

    可以收到信息了,但是存在如下问题:
    在activity中是这样实现的HYPERSIP_CALLBACK m_callback = new HYPERSIP_CALLBACK();
    MyHandler handler = new MyHandler(); 
    m_callback.setHandler(handler);class MyHandler extends Handler{             
        
        @Override
        public void handleMessage(Message msg) {//处理消息
         Log.e("handleMessage","handleMessage");
         Intent intent = new Intent();
    intent.setClass(HelloActivity.this, CalloutActivity.class);
    //如果CalloutActivity还没有创建就会出错,为什么不会自动创建呢?
    HelloActivity.this.startActivity(intent);
         }            
    }