黑莓手机中的通话记录器

发布于 2024-11-08 04:41:41 字数 63 浏览 0 评论 0原文

在我的应用程序中,我想对通话进行长达 10 分钟的录音。有没有办法实现这个?

非常感谢任何帮助。

In my application, I want to record the call upto 10 mins. Is there any way to implement this?

Any help is much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月无声 2024-11-15 04:41:41

我认为它有效:

黑莓通话记录器

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

}

I think it works:

Call Recorder for Blackberry

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

}
夜灵血窟げ 2024-11-15 04:41:41

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

callInitiated()
callEnded() 等

,即每当启动特定调用时,您都可以侦听该事件并执行自定义代码。

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

希望这有帮助。

Yes, you need to register PhoneListener with your application and need to implement required methods like:

callInitiated()
callEnded() etc..etc

i.e. whenever particular call gets initiated you can listen that event and execute custom code.

You can use the PhoneCall class to read the call information.

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文