BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-03-2008, 06:40 AM   #1 (permalink)
New Member
 
Join Date: Jun 2008
Model: 8130
PIN: N/A
Carrier: sprint
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Repeat notifications (free)

Please Login to Remove!

Hello,

By default, bb can only do repeat notifications by LED.
can someone create a free bb software to play repeat notifications with sound/vibrate? There need not be a lot of options, just simple and fast.

I know there are some 3rd party apps that can do this, but I have not been able to find a free one.

thank you.
Offline  
Old 08-11-2008, 02:07 AM   #2 (permalink)
New Member
 
Join Date: Jun 2008
Model: 8130
PIN: N/A
Carrier: sprint
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok. I've found how to find missed calls by using PhoneLogs, and to make sounds/vibrations by using a rim demo code.

I need to figure out how to let the program run in background and react to changes to phonelogs.

Questions:
1.How do I implement a Listener (specifically PhoneLogListener)? My listener does not appear to be receiving events even though I registered by listener.
2.How does one make sounds/vibractions without user directly opening my program?

code so far:
Code:
/*
 * LogReader.java
 * GPL'ed
 */
package freebbalerts;
import net.rim.blackberry.api.phone.phonelogs.*;
import java.lang.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

public class LogReader extends UiApplication implements PhoneLogListener{
    private PhoneLogs _logs;
    private String _missedCalls;
    static public void main(String[] args) {
        LogReader app = new LogReader();
        app.enterEventDispatcher();
        PhoneLogs.addListener(app);
    }
    
    private LogReader() {
        _logs = PhoneLogs.getInstance();
        _missedCalls = findMissedCalls(PhoneLogs.FOLDER_MISSED_CALLS);
        pushScreen(new LogReaderScreen(_missedCalls));
    }
    
    public String findMissedCalls(long folder) {
        int totalCalls = this._logs.numberOfCalls(folder);
        int missedCalls = 0;
        for(int i=0;i<totalCalls;i++){
            PhoneCallLog cl = (PhoneCallLog) _logs.callAt(i,folder);
            if(cl.getType() == PhoneCallLog.TYPE_MISSED_CALL_UNOPENED){
                missedCalls++;
            }
        }
        return Integer.toString(missedCalls);
    }
    
    public void callLogAdded(CallLog cl){
        System.out.println("added");
        ConsequenceDemo cDemo = new ConsequenceDemo();
        cDemo.startN();
        
        _logs = PhoneLogs.getInstance();
        _missedCalls = findMissedCalls(PhoneLogs.FOLDER_MISSED_CALLS);
        pushScreen(new LogReaderScreen(_missedCalls));
    }
    
    public void callLogRemoved(CallLog cl){
        System.out.println("removed");
        
    }
    public void callLogUpdated(CallLog cl, CallLog Oldcl){
        System.out.println("updated");
    }
    public void reset(){
        _logs = PhoneLogs.getInstance();
    }
}

final class LogReaderScreen extends MainScreen{
    private LabelField _lf;
    public LogReaderScreen(String missedCalls){
        super();
        _lf = new LabelField();
        add(_lf);
        monitorLog(missedCalls);
    }
    public void monitorLog(String missedCalls){
        _lf.setText(missedCalls + " number of missed calls." );
        if(missedCalls!="0"){
            ConsequenceDemo cDemo = new ConsequenceDemo();
            cDemo.startN();
        }
    }
}
This is demo code from rim
Code:
/**
* ConsequenceDemo.java
*/
package freebbalerts;
import net.rim.device.api.synchronization.*;
import net.rim.device.api.notification.*;
import net.rim.device.api.system.*;
import net.rim.device.api.util.*;
import java.io.*;
public class ConsequenceDemo implements Consequence, SyncConverter {
    public static final long ID = 0xbd2350c0dfda2a51L;
    private static final int TYPE = 'n' << 24 | 'o' << 16 | 't' << 8 | 'd';
    private static final byte[] DATA = new byte[] {
            'm', 'y', '-', 'c', 'o', 'n', 'f', 'i',
            'g', '-', 'o', 'b', 'j', 'e', 'c', 't' };
    private static final Configuration CONFIG = new Configuration(DATA);
    private static final short BFlat = 466; // The actual value is 466.16.
    private static final short TEMPO = 125;
    private static final short d16 = 1 * TEMPO;
    private static final short pause = 10; // 10 millisecond pause.
    private static final short[] TUNE = new short[] {BFlat, d16, pause, BFlat};
    private static final int VOLUME = 80; // Percentage volume.
    
    
    public void startNotification(long consequenceID, long sourceID, long eventID,
                                    Object configuration, Object context) {
        LED.setConfiguration(500, 250, LED.BRIGHTNESS_100);
        LED.setState(LED.STATE_BLINKING);
        Alert.startAudio(TUNE, VOLUME);Alert.startAudio(TUNE, VOLUME);Alert.startAudio(TUNE, VOLUME);
        Alert.startBuzzer(TUNE, VOLUME);
        Alert.startVibrate(3000);
    }
    
    public void startN(){
        startNotification(1,ID,1,(Object)"", (Object)"");
    }
    
    public void stopNotification(long consequenceID, long sourceID, long eventID,
                                    Object configuration, Object context) {
        LED.setState(LED.STATE_OFF);
        Alert.stopAudio();
        Alert.stopBuzzer();
    }
    public Object newConfiguration(long consequenceID, long sourceID,
        byte profileIndex, int level, Object context) {
        return CONFIG;
    }
    public SyncObject convert(DataBuffer data, int version, int UID) {
        try {
            int type = data.readInt();
            int length = data.readCompressedInt();
            if ( type == TYPE ) {
            byte[] rawdata = new byte[length];
            data.readFully(rawdata);
            return new Configuration(rawdata);
            }
        } catch (EOFException e) {
            System.err.println(e);
        }
        return null;
    }
    public boolean convert(SyncObject object, DataBuffer buffer, int version) {
        boolean retval = false;
        if ( object instanceof Configuration ) {
            Configuration c = (Configuration)object;
            buffer.writeInt(TYPE);
            buffer.writeCompressedInt(c._data.length);
            buffer.write(c._data);
            retval = true;
            }
        return retval;
    }
    
/* Inner class to store configuration profile. */
private static final class Configuration implements SyncObject, Persistable {
    public byte[] _data;
    public Configuration(byte[] data) {
        _data = data;
    }
    public int getUID() {
        return 0;
    }
    }
}

Last edited by lolplz : 08-11-2008 at 02:10 AM.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.