Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
abhishek92
Posts: 85
Registered: ‎12-02-2013
My Device: 9360 Curve
Accepted Solution

Fetching value from a conference call log and add call logs to call log list programmatically

Hello everyone,

 

I want to add call logs programmatically into call logs list,i want to fetch data from a ConferenceCallLog and from this data i want to make a new Normal Call log, i am fetching these data from ConferenceCallLog callDuration,callStatus,participant,notes,date. here is my code for this:

 

public void callLogAdded(CallLog callLog) {
  

   if(callLog instanceof ConferencePhoneCallLog){
           
            ConferencePhoneCallLog newLog =  (ConferencePhoneCallLog)callLog;
         int   callType= PhoneCallLog.TYPE_PLACED_CALL;
         int  callDuration = newLog.getDuration();
         int   callStatus = newLog.getStatus();
            
    PhoneCallLogID     participant = newLog.getParticipantAt(0);
        String    notes = newLog.getNotes();
          Date   date = new Date(callLog.getDate().getTime());


              try {
                Thread.sleep(1000);
                new Thread(new Runnable() {
                      public void run() {
                      
                         phn.addCall(new PhoneCallLog(date, callType, callDuration, PhoneCallLog.STATUS_NORMAL,   participant, notes));
                    }
                }).start();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
               
            }
             }
        }

but call log didn't added to call logs list. plz help me

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Fetching value from a conference call log and add call logs to call log list programmatically

i guess phn is an instance of PhoneLogs?
check if the PhoneCallLog object is correctly created by calling one of its attributes.
add a logging line below to check if the code runs successfully.
Then add it to the PhoneLogs
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
abhishek92
Posts: 85
Registered: ‎12-02-2013
My Device: 9360 Curve

Re: Fetching value from a conference call log and add call logs to call log list programmatically

[ Edited ]

Thanks for your quick reply simon, yes phn is an instance of PhoneLogs, i forgot to write it. ok i will do it and get back to you soon if any problem is there.

 

i didn't get you what you mean here "check if the PhoneCallLog object is correctly created by calling one of its attributes. add a logging line below to check if the code runs successfully."

 

Below is my complete code

 

int callType;
    int callDuration;
    int callStatus;
    PhoneCallLogID participant;
    String notes;
    Date date;
    PhoneLogs phn = PhoneLogs.getInstance();
    PhoneCallLog calllogs = null;

    public void init() {
        PhoneLogs.addListener(this);
    }

    public void callLogAdded(CallLog callLog) {
        // TODO Auto-generated method stub

        if (callLog instanceof ConferencePhoneCallLog) {
            ConferencePhoneCallLog newLog = (ConferencePhoneCallLog) callLog;

            callType = PhoneCallLog.TYPE_PLACED_CALL;
            callDuration = newLog.getDuration();
            callStatus = newLog.getStatus();

            participant = newLog.getParticipantAt(0);

            notes = newLog.getNotes();
            date = new Date(callLog.getDate().getTime());

            calllogs = new PhoneCallLog(date, callType, callDuration,
                    PhoneCallLog.STATUS_NORMAL, participant, notes);

            try {
                Thread.sleep(1000);
                new Thread(new Runnable() {

                    public void run() {
                        phn.addCall(calllogs);
                    }
                }).start();
            } catch (InterruptedException e) {
                e.printStackTrace();
                System.out.println(e.toString());
            }

            System.out.println();
        }

    }

    public void callLogRemoved(CallLog cl) {

    }

    public void callLogUpdated(CallLog cl, CallLog oldCl) {

    }

    public void reset() {

    }

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Fetching value from a conference call log and add call logs to call log list programmatically

try the code in your app, for example with a menu item or by pressing a button.
is the call log added, then? just to check the validity of your code.

Note that the Thread.sleep must be inside the threads run method, at the moment you block the listener with it which is bad.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
abhishek92
Posts: 85
Registered: ‎12-02-2013
My Device: 9360 Curve

Re: Fetching value from a conference call log and add call logs to call log list programmatically

Hello simon,

 

i followed your last post and did as you suggested in the post, call logs added successfully when i pressed a button here is my code:

 

 public MyScreen()
    {        
        setTitle("MyTitle");
         ButtonField type = new ButtonField("Add Call Log", Field.FIELD_HCENTER);
        type.setChangeListener(this);
        add(type);
    }

    public void fieldChanged(Field field, int context) {
        final PhoneLogs phn = PhoneLogs.getInstance();
        final int callType = PhoneCallLog.TYPE_PLACED_CALL;
        final int callDuration = 60;
        final PhoneCallLogID participant = new PhoneCallLogID("1234567890");
        final String notes = "Hi this is test";
        final Date date = new Date(100000);
        
        new Thread(new Runnable() {
            
            public void run() {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                phn.addCall(new PhoneCallLog(date, callType, callDuration, (int) PhoneLogs.FOLDER_NORMAL_CALLS, participant, notes));
            }
        }).start();
        }

 

but same thing doesn't happen when i do this:

 

public void callLogAdded(CallLog cl) {
        if(cl instanceof ConferencePhoneCallLog){
            ConferencePhoneCallLog newLog = (ConferencePhoneCallLog) cl;
            final PhoneLogs phn = PhoneLogs.getInstance();
            callType = PhoneCallLog.TYPE_PLACED_CALL;
            callDuration = newLog.getDuration();
            participant = newLog.getParticipantAt(0);
            notes = newLog.getNotes();
            date = new Date(cl.getDate().getTime());
            new Thread(new Runnable() {
                
                public void run() {
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    phn.addCall(new PhoneCallLog(date, callType, callDuration, (int) PhoneLogs.FOLDER_NORMAL_CALLS, participant, notes));
                
                }
            }).start();
        }
    }

 

please suggest me what to do now and thanks for your help.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Fetching value from a conference call log and add call logs to call log list programmatically

put logging into the listener method. is it executed?

if yes, put the exact same code from your screen there. does it run?

go step by step until you encounter something not working
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
abhishek92
Posts: 85
Registered: ‎12-02-2013
My Device: 9360 Curve

Re: Fetching value from a conference call log and add call logs to call log list programmatically

Thank you very much simon you are always appreciated