SIP Android应用程序,如何使用服务和活动 [英] SIP Android app, how to use services and activities

查看:114
本文介绍了SIP Android应用程序,如何使用服务和活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我爱的是有人可以点我一些很好的资源,或在正确的方向,甚至更好泵出一些code片段/伪code来帮助我在这里。

I would love is someone could point me to some good resources or in the right direction, or even better pump out some code snippets/pseudo code to help me here.

我是新来的Andr​​oid devel软件包我一直在负责创建一个应用程序,它使用SIP库,使/免费获赠SIP呼叫。该库是相当抽象,所有与手机实例的工作,我可以叫.rejectCall(),.answerCall()等等等等。拿到手机的情况下,我使用这行:

I'm new to android devel and I've been tasked to create an app which uses a sip library to make/recieve sip calls. The library is fairly abstracted and all works with a 'phone' instance which I can call .rejectCall(), .answerCall() and so on and so forth. To get the instance of the phone, i use this line:

AbtoPhone abtoPhone = ((AbtoApplication)getApplication()).getAbtoPhone();

这就是所有罚款和花花公子,但不认识活动和服务正确我不知道如何去把它变成一个应用程序。

Thats all fine and dandy, but not understanding Activities and Services properly I'm not sure how to go about turning it into an app.

我想登录,注册SIP服务器,然后让手机将监听呼叫的能力的用户。

I want the ability for a user to log in, register with a sip server and then let the phone will listen for calls.

我希望它继续的时候投入的背景通话监听。而当在后台我要弹出一个对话框,允许有人接听或拒绝来电,并回答我想intial活动唤醒(或者它被杀死的话,我希望它启动),并提请前台,使用户可以聊开了288。

I want it to continue to listen for calls when put into the background. And when in background I want to pop up a dialog that allows someone to answer or reject call, and on answer I want the intial activity to wake up (or if its been killed then i want it to start up) and be brought to the foreground so the user can chat away merrily.

我最好如何去做?目前我得到的主要活动AbtoPhone,添加帐户,将所有的听众,然后当用户点击注册按钮启动一个棘手的服务,得到了手机自身的实例,使用相同的命令和以前一样。

How do I best go about it? At the moment I'm getting the AbtoPhone in the main activity, adding the account, adding all the listeners, and then when a user hits the register button it starts a sticky service which gets its own instance of the phone, with the same command as before.

然后,服务内,我注册到SIP客户端用户。现在,当我关闭这个继续运行的主要活动,它会接听电话,但它会抛出异常崩溃:

Then, within the service, I register the user with the sip client. Now when I close the main activity this continues to run and it will receive a call, however it will crash with an exception:

android.view.WindowManager$BadTokenException: Unable to add window 
-- token android.os.BinderProxy@4154ebb0 is not valid; 
is your activity running?

我得到了我的问题是原来的活动,称为服务已经死了,我试图唤醒它。但我就是不知道该怎么做正确的。

I get that my problem is the original activity that called the service is dead and I'm trying to wake it. But I just don't know how to do that properly.

我得到的服务和活动是一个重复的问题,我环顾四周,阅读教程,但是我看不到如何正确地将它们应用到我的情况,而只是希望有人能够说做X,启动服务,通这一点,当你得到一个呼叫做Y和瞧!但任何帮助什么那么将是极大的,pciated !!!大大AP $ P $

I get that Services and Activities is a repeated question, and I have looked around read tutorials however I cant see how to properly apply them to my case, and just hoping someone will be able to say Do X, Start service, Pass this, When you get a call do Y and VOILA! But any help what so ever will be greatly, greatly appreciated!!!

干杯,

DJOodle

>>>>修改

好吧,我搬到了AbtoPhone所有处理到服务。当我接到一个电话我然后调用MainActivity,将其绑定到该服务,这样我就可以调用正确的方法来接听电话。

Ok, I've moved all handling of the AbtoPhone to a service. When i get a call i then invoke the MainActivity, bind it to the service, so i can invoke the correct methods to answer the call.

这是很好,它的工作原理然而,这意味着我有一个始终运行的持续性服务,给我的感觉,这是一个坏,坏的事情。我怎样才能保持AbtoPhone的一个实例,听走了进来的电话不会耗尽手机的资源?

This is fine and it works however this means I've got a persistent service that is always running, and i get the feeling that's a bad, bad thing. How can i keep an instance of AbtoPhone listening away for incomming calls without draining the resources of the phone?

干杯!

推荐答案

这是一个很大的话题。我想你应该给SIP的Droid的是一个开放源代码的应用程序的机会。所以你可以使用任何与它有关。

This is a big topic. I think you should give Sip-Droid which is an open-source application a chance. so you can use anything related to it.

http://code.google.com/p/sipdroid/

这是一个基于SIP的应用程序,做一切你问。我认为你可以使用你想从它的源$ C ​​$ c和再开发任何东西。 这个应用程序使用JNI比品尝更复杂的话题。所以使用所有JNI在这个应用程序,你会发现很多lib中,你可以使用,使工作更快。

this is a Sip based application that does everything you asked for. I think you can use the source code and redeveloped anything you want from it. this application uses JNI which is more complicated topic than Sip. so use all JNI's in this app and you will find lots of lib that you can use and make the works faster.

这篇关于SIP Android应用程序,如何使用服务和活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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