Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Blackberry 黑莓手机中的通话记录器_Blackberry_Recorder - Fatal编程技术网

Blackberry 黑莓手机中的通话记录器

Blackberry 黑莓手机中的通话记录器,blackberry,recorder,Blackberry,Recorder,在我的应用程序中,我想记录通话时间长达10分钟。有什么方法可以实现这一点吗 非常感谢您的帮助。是的,您需要在应用程序中注册PhoneListener,并需要实现所需的方法,如: callInitiated() callEnded()etc..etc i、 e.无论何时启动特定调用,您都可以侦听该事件并执行自定义代码 您可以使用PhoneCall类来读取通话信息 希望这有帮助。是的,您需要在应用程序中注册PhoneListener,并需要实现所需的方法,如: callInitiated() cal

在我的应用程序中,我想记录通话时间长达10分钟。有什么方法可以实现这一点吗


非常感谢您的帮助。

是的,您需要在应用程序中注册
PhoneListener
,并需要实现所需的方法,如:

callInitiated()
callEnded()
etc..etc

i、 e.无论何时启动特定调用,您都可以侦听该事件并执行自定义代码

您可以使用
PhoneCall
类来读取通话信息


希望这有帮助。

是的,您需要在应用程序中注册
PhoneListener
,并需要实现所需的方法,如:

callInitiated()
callEnded()
etc..etc

i、 e.无论何时启动特定调用,您都可以侦听该事件并执行自定义代码

您可以使用
PhoneCall
类来读取通话信息

希望这能有所帮助。

我认为它有效:

黑莓电话录音机

public final class MyScreen extends MainScreen {
    /**
     * Creates a new MyScreen objects
     * 
     */
    Player player;
    RecordControl recorder;
    private ByteArrayOutputStream output;
    byte[] data;
    boolean yes = false;
    int st;

    public MyScreen() {
        // Set the displayed title of the screen
        setTitle("Call Recorder");
        Phone.addPhoneListener(new PhoneListener() {

            public void conferenceCallDisconnected(int callId) {
                // TODO Auto-generated method stub

            }

            public void callWaiting(int callid) {
                // TODO Auto-generated method stub

            }

            public void callResumed(int callId) {
                // TODO Auto-generated method stub

            }

            public void callRemoved(int callId) {
                // TODO Auto-generated method stub

            }

            public void callInitiated(int callid) {
                PhoneCall phoneCall = Phone.getCall(callid);
                if (phoneCall != null) {
                    st = Dialog.ask(Dialog.D_YES_NO,
                            "Are u sure to record this call");
                    if (st == Dialog.YES)
                        yes = true;
                    else
                        yes = false;
                    // TODO Auto-generated method stub
                }
            }

            public void callIncoming(int callId) {
                // TODO Auto-generated method stub

                // TODO Auto-generated method stub
                Dialog.ask(Dialog.D_YES_NO, "Are u sure to record this call");

                // TODO Auto-generated method stub

            }

            public void callHeld(int callId) {
                // TODO Auto-generated method stub

            }

            public void callFailed(int callId, int reason) {
                // TODO Auto-generated method stub

            }

            public void callEndedByUser(int callId) {
                // TODO Auto-generated method stub

            }

            public void callDisconnected(int callId) {
                // TODO Auto-generated method stub
                if (yes) {
                    try {
                        recorder.commit();

                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    player.close();
                    data = output.toByteArray();
                    saveRecordedFile(data);
                }

            }

            public void callDirectConnectDisconnected(int callId) {
                // TODO Auto-generated method stub

            }

            public void callDirectConnectConnected(int callId) {
                // TODO Auto-generated method stub

            }

            public void callConnected(int callId) {
                // TODO Auto-generated method s
                PhoneCall phoneCall = Phone.getCall(callId);
                if (phoneCall != null) {
                    if (yes)
                        initPlay();
                }

            }

            public void callConferenceCallEstablished(int callId) {
                // TODO Auto-generated method stub

            }

            public void callAnswered(int callId) {
                // TODO Auto-generated method stub

                // yes = true;

                // TODO Auto-generated method stub

            }

            public void callAdded(int callId) {
                // TODO Auto-generated method stub

            }
        });

    }

    // private void initMenuItem() {
    // final String[] path = new String[1];
    // ApplicationDescriptor appDesc = ApplicationDescriptor
    // .currentApplicationDescriptor();
    //
    // final ApplicationDescriptor newDesc = new ApplicationDescriptor(
    // appDesc, path);
    //
    // ApplicationMenuItemRepository amir = ApplicationMenuItemRepository
    // .getInstance();
    // ApplicationMenuItem a = new ApplicationMenuItem(1) {
    // public Object run(final Object context) {
    // Application.getApplication().invokeLater(new Runnable() {
    //
    // public void run() {
    //
    // }
    // });
    //
    // return context;
    // }
    //
    // public String toString() {
    // return "Record Call";
    // }
    //
    // };
    // amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_PHONE, a,
    // newDesc);
    //
    // }

    private void initPlay() {
        // TODO Auto-generated method stub
        try {
            player = Manager.createPlayer("capture://audio");
            player.realize();
            recorder = (RecordControl) player.getControl("RecordControl");
            output = new ByteArrayOutputStream();
            recorder.setRecordStream(output);
            recorder.startRecord();
            player.start();
        } catch (Exception e) {
            // TODO: handle exception
            Dialog.alert(e + "");
        }

    }

    public static boolean saveRecordedFile(byte[] data) {
        try {
            String filePath1 = System.getProperty("fileconn.dir.music");
            String fileName = "Call Recorder(";
            boolean existed = true;
            for (int i = 0; i < Integer.MAX_VALUE; i++) {
                try {

                    FileConnection fc = (FileConnection) Connector
                            .open(filePath1 + fileName + i + ").amr");

                    if (!fc.exists()) {
                        existed = false;
                    }
                    fc.close();
                } catch (IOException e) {
                    Dialog.alert("unable to save");
                    return existed;
                }
                if (!existed) {
                    fileName += i + ").amr";
                    filePath1 += fileName;
                    break;
                }
            }
            System.out.println(filePath1);
            // output---file:///store/home/user/pictures/Photo Editor(10).bmp
            System.out.println("");

            FileConnection fconn = (FileConnection) javax.microedition.io.Connector
                    .open(filePath1, javax.microedition.io.Connector.READ_WRITE);

            if (fconn.exists())
                fconn.delete();

            fconn.create();

            OutputStream outputStream = fconn.openOutputStream();
            outputStream.write(data);
            outputStream.close();
            fconn.close();
            return true;
        } catch (Exception e) {
        }
        return false;
    }

}
public final class MyScreen扩展主屏幕{
/**
*创建新的MyScreen对象
* 
*/
玩家;
记录控制记录器;
私有ByteArrayOutputStream输出;
字节[]数据;
布尔值yes=false;
int st;
公共MyScreen(){
//设置屏幕显示的标题
setTitle(“通话录音机”);
addPhoneListener(新的PhoneListener(){
公共无效会议CallDisconnected(int callId){
//TODO自动生成的方法存根
}
公共无效呼叫等待(int callid){
//TODO自动生成的方法存根
}
公共无效调用恢复(int callId){
//TODO自动生成的方法存根
}
已删除公共无效调用(int callId){
//TODO自动生成的方法存根
}
公共无效callInitiated(内部callid){
PhoneCall=Phone.getCall(callid);
if(phoneCall!=null){
st=Dialog.ask(Dialog.D_YES_NO,
“您确定要录制此通话吗”);
如果(st==Dialog.YES)
是=正确;
其他的
是=假;
//TODO自动生成的方法存根
}
}
公共无效调用(内部调用){
//TODO自动生成的方法存根
//TODO自动生成的方法存根
询问(Dialog.D_YES_NO,“您确定要录制此通话吗”);
//TODO自动生成的方法存根
}
公共无效呼叫保持(内部呼叫){
//TODO自动生成的方法存根
}
public void callFailed(int callId,int reason){
//TODO自动生成的方法存根
}
被调用的公共无效数据(int callId){
//TODO自动生成的方法存根
}
公共无效调用已断开连接(int callId){
//TODO自动生成的方法存根
如果(是){
试一试{
recorder.commit();
}捕获(IOE异常){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
player.close();
data=output.toByteArray();
保存的记录文件(数据);
}
}
public void callDirectConnectDisconnected(int callId){
//TODO自动生成的方法存根
}
public void callDirectConnectConnected(int callId){
//TODO自动生成的方法存根
}
公共无效调用连接(int callId){
//TODO自动生成的方法s
PhoneCall=Phone.getCall(callId);
if(phoneCall!=null){
如果(是)
initPlay();
}
}
公共无效callConferenceCallEstablished(int callId){
//TODO自动生成的方法存根
}
公共无效呼叫已应答(int CALID){
//TODO自动生成的方法存根
//是=正确;
//TODO自动生成的方法存根
}
已添加公共无效调用(int callId){
//TODO自动生成的方法存根
}
});
}
//私有void initMenuItem(){
//最终字符串[]路径=新字符串[1];
//ApplicationDescriptor appDesc=ApplicationDescriptor
//.currentApplicationDescriptor();
//
//最终ApplicationDescriptor newDesc=新ApplicationDescriptor(
//appDesc,路径);
//
//ApplicationMenuItemRepository amir=ApplicationMenuItemRepository
//.getInstance();
//ApplicationMenuItem a=新的ApplicationMenuItem(1){
//公共对象运行(最终对象上下文){
//Application.getApplication().invokeLater(新的Runnable()){
//
//公开募捐{
//
// }
// });
//
//返回上下文;
// }
//
//公共字符串toString(){
//返回“记录呼叫”;
// }
//
// };
//amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM\u电话,a,
//纽德斯克);
//
// }
私人游戏{
//TODO自动生成的方法存根
试一试{
player=Manager.createPlayer(“capture://audio");
player.realize();
recorder=(RecordControl)player.getControl(“RecordControl”);
输出=新的ByteArrayOutputStream();
setRecordStream(输出);
录音机;
player.start();
}捕获(例外e){
//TODO:处理异常