Strange BlackBerry log

2019-06-06 14:20发布

问题:

I am using the code below , as part of my push notifications implementation:

private static final String BPAS_URL = "http://pushapi.eval.blackberry.com";
private static final String APP_ID = "3582-M4687r9k9k836r980kO2395i32i66y11a34";

String registerUrl = formRegisterRequest(BPAS_URL, APP_ID, null) + ";deviceside=false;ConnectionType=mds-public";

System.out.println("\n\n\n !!msg registerBPAS URL is:  "+ registerUrl + "\n\n");

where :

private static String formRegisterRequest(String bpasUrl, String appId, String token) {
    StringBuffer sb = new StringBuffer(bpasUrl);
    sb.append("/mss/PD_subReg?");
    sb.append("serviceid=").append(appId);
    sb.append("&osversion=").append(DeviceInfo.getSoftwareVersion());
    sb.append("&model=").append(DeviceInfo.getDeviceName());
    if (token != null && token.length() > 0) {
        sb.append("&").append(token);
    }
    return sb.toString();
}

What i get printed is this :

!!msg registerBPAS URL is:  http://pushapi.eval.blackberry.com/mss/PD_subReg?serviceid=3582-M4687r9[0.0] k9k836r980kO2395i32i66y11a34&osversion=5.0.0.669&model=9520;deviceside=false;ConnectionType=mds-publ[0.0] ic

I cant understand why though. Why there are spaces " " in the URL and why is there a "[0.0]"

From the code above i cant explain this behavior.

What i would expect to be printed is this:

!!msg registerBPAS URL is:  http://pushapi.eval.blackberry.com/mss/PD_subReg?serviceid=3582-M4687r9k9k836r980kO2395i32i66y11a34&osversion=5.0.0.669&model=9520;deviceside=false;ConnectionType=mds-public

*I dont have BIS enabled if this is any help , but i dont think it matters as i am forming the URL locally.

回答1:

All you're seeing is an extra [0.0] in your log in a couple places.

This is normal ... your URL is fine.

Calling

System.out.println("");

does not give you exclusive, or atomic, access to stdout. In other words, while the log is printing out the String you passed to println(), you can also get these tokens printed to the log, and other messages from the BlackBerry OS, and they may/will be placed right in the middle of your log output.

It's annoying, but there's nothing wrong with your code.

If you want another option, look at the BlackBerry EventLogger API, which writes to a log that you can pull off the device, and search through for your messages, without the annoying [0.0].