本文介绍了如何记录调用黑莓?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个黑莓通话记录器应用程序。虽然在这个论坛搜索我有call-recorder-in-blackberry此链接。在下面的链接中给出的code是相当了解。

这可能是你的专家愚蠢的问题,但我的问题是如何对我们的那件code的。我的意思是自选对象将在UIApplication的工作。但是怎样才能让我的模块启动,同时启动的设备,并在后台运行等待电话监听器调用。


我已经使用这个低于code,它记录了电话,但只有在呼叫处于外放模式。现在我该怎么办同样没有投入外放模式。

 进口java.io.ByteArrayOutputStream中;
进口java.io.IOException异常;
进口java.io.OutputStream中;进口javax.microedition.io.Connector;
进口javax.microedition.io.file.FileConnection;
进口javax.microedition.media.Manager;
进口的javax.microedition.media.Player;
进口javax.microedition.media.control.RecordControl;进口net.rim.blackberry.api.phone.Phone;
进口net.rim.blackberry.api.phone.PhoneCall;
进口net.rim.blackberry.api.phone.PhoneListener;
进口net.rim.device.api.system.Application;
进口net.rim.device.api.ui.component.Dialog;公共类CatchCall扩展应用实现PhoneListener {    Player播放器;
    RecordControl记录;
    私人ByteArrayOutputStream输出;
    字节[]数据;
    Boolean是= FALSE;
    。INT ST;    公共CatchCall(){
        Phone.addPhoneListener(本);
    }    公共静态无效的主要(字串[] args){
        新CatchCall()enterEventDispatcher()。
    }    公共无效callAdded(INT CALLID){
    }    公共无效callAnswered(INT CALLID){
    }    公共无效callConferenceCallEstablished(INT CALLID){
    }    公共无效callConnected(INT CALLID){        // TODO自动生成方法S
        PhoneCall phoneCall = Phone.getCall(CALLID);
        如果(phoneCall!= NULL){
            如是)
                initPlay();
        }
    }    公共无效callDirectConnectConnected(INT CALLID){
    }    公共无效callDirectConnectDisconnected(INT CALLID){
    }    公共无效callDisconnected(INT CALLID){
        // TODO自动生成方法存根
        如是) {
            尝试{
                recorder.commit();            }赶上(IOException异常五){
                // TODO自动生成catch块
                e.printStackTrace();
            }
            player.close();
            数据= output.toByteArray();
            saveRecordedFile(数据);
        }
    }    公共无效callEndedByUser(INT CALLID){
    }    公共无效callFailed(INT CALLID,诠释原因){
    }    公共无效callHeld(INT CALLID){
    }    公共无效callIncoming(INT CALLID){
        Dialog.ask(Dialog.D_YES_NO,有U一定要录下通话);
    }    公共无效callInitiated(INT CALLID){        PhoneCall phoneCall = Phone.getCall(CALLID);
        如果(phoneCall!= NULL){
            ST = Dialog.ask(Dialog.D_YES_NO,有U一定要录下通话);
            如果(ST == Dialog.YES)
                是= TRUE;
            其他
                是= FALSE;
        }    }    公共无效callRemoved(INT CALLID){
    }    公共无效callResumed(INT CALLID){
    }    公共无效来电等待(INT CALLID){
    }    公共无效conferenceCallDisconnected(INT CALLID){
    }    私人无效initPlay(){
        尝试{
            玩家= Manager.createPlayer(捕获://音频);
            player.realize();
            录音机=(RecordControl)player.getControl(RecordControl);
            输出=新ByteArrayOutputStream();
            recorder.setRecordStream(输出);
            recorder.startRecord();
            player.start();
        }赶上(例外五){
            Dialog.alert(E +);
        }    }    公共静态布尔saveRecordedFile(字节[]数据){
        尝试{
            串filePath1 = System.getProperty(fileconn.dir.music);
            字符串文件名=通话记录(;
            布尔存在= TRUE;
            的for(int i = 0; I< Integer.MAX_VALUE的;我++){
                尝试{
                    FC的FileConnection =(的FileConnection)Connector.open(filePath1 +文件名+ I +).AMR);
                    如果(!fc.exists()){
                        存在= FALSE;
                    }
                    fc.close();
                }赶上(IOException异常五){
                    Dialog.alert(无法​​保存);
                    回报存在;
                }
                如果(!存在){
                    文件名+ = I +).AMR;
                    filePath1 + =文件名;
                    打破;
                }
            }
            的System.out.println(filePath1);
            的System.out.println();
            fconn的FileConnection =(的FileConnection)javax.microedition.io.Connector。开(filePath1,javax.microedition.io.Connector.READ_WRITE);
            如果(fconn.exists())
                fconn.delete();
            fconn.create();            为OutputStream的OutputStream = fconn.openOutputStream();
            outputStream.write(数据);
            outputStream.close();
            fconn.close();
            返回true;
        }赶上(例外五){
        }
        返回false;
    }
}


解决方案

其实直接通话录音不可能的黑莓。据我所知这贴code是通话录音时使用免提通话。这意味着如果手机有外放,然后把调用外放并记录声音。看看这个讨论,黑莓

I want to create an call recorder application in blackberry. While searching in this forum i have got call-recorder-in-blackberry this link. The code given in the below link is fairly understood.

It might be a silly question to you experts but my question is how to us that piece of code. I mean the MyScreen object will work on UIApplication. But how can i make my module start while starting the device, and run in background waiting for the phone call listener to invoke.


I have used this below code, it records the call but only if the call is on loud speaker mode. Now how can i do the same without putting in loud speaker mode.

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.media.control.RecordControl;

import net.rim.blackberry.api.phone.Phone;
import net.rim.blackberry.api.phone.PhoneCall;
import net.rim.blackberry.api.phone.PhoneListener;
import net.rim.device.api.system.Application;
import net.rim.device.api.ui.component.Dialog;

public class CatchCall extends Application implements PhoneListener {

    Player player;
    RecordControl recorder;
    private ByteArrayOutputStream output;
    byte[] data;
    boolean yes = false;
    int st;

    public CatchCall() {
        Phone.addPhoneListener(this);
    }

    public static void main(String[] args) {
        new CatchCall().enterEventDispatcher();
    }

    public void callAdded(int callId) {
    }

    public void callAnswered(int callId) {
    }

    public void callConferenceCallEstablished(int callId) {
    }

    public void callConnected(int callId) {

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

    public void callDirectConnectConnected(int callId) {
    }

    public void callDirectConnectDisconnected(int callId) {
    }

    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 callEndedByUser(int callId) {
    }

    public void callFailed(int callId, int reason) {
    }

    public void callHeld(int callId) {
    }

    public void callIncoming(int callId) {
        Dialog.ask(Dialog.D_YES_NO, "Are u sure to record this call");
    }

    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;
        }

    }

    public void callRemoved(int callId) {
    }

    public void callResumed(int callId) {
    }

    public void callWaiting(int callid) {
    }

    public void conferenceCallDisconnected(int callId) {
    }

    private void initPlay() {
        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) {
            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);
            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;
    }
}
解决方案

Actually direct call recording not possible with blackberry. AFAIK that posted code is call recording when call on speakerphone. That means If mobile have the loud speaker, then put a call to loud speaker and record that voice. And look at this discussion, Call recorder in Blackberry.

这篇关于如何记录调用黑莓?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 01:00