2013-02-23 79 views
0

我已经开发了RSS阅读器应用程序,当我执行的应用程序上BB模拟器9900,我能够成功地显示列表项,黑莓RSS喂不装上设备

但是,同样的应用程序时,我尝试要在我的真实设备BB Curve 9380上执行,我无法加载我的列表项目。

难道有人告诉我发生了什么错吗?

注:当我跑我的真实设备上的应用,我与显示* 饲料在屏幕上

这里我的代码不能使用*消息:

public class RssScreen extends MainScreen implements ListFieldCallback { 

public RssScreen() { 

    subManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL 
    | Manager.VERTICAL_SCROLLBAR) { 
    protected void sublayout(int maxWidth, int maxHeight) { 
    int displayWidth=Display.getWidth(); 
    int displayHeight = Display.getHeight(); 
    super.sublayout(displayWidth, displayHeight); 
    setExtent(displayWidth, displayHeight); 
    } 
    }; 

    _list = new ListField() 
    { 
    protected boolean navigationClick(int status, int time) { 
    return true; 
    } 
    public void paint(Graphics graphics) 
    { 
    graphics.setColor((int) mycolor); 
    super.paint(graphics); 
    } 
    }; 
    mycolor = 0x00FFFFFF; 
    _list.invalidate(); 
    _list.setEmptyString("* Feeds Not Available *", DrawStyle.HCENTER); 
    _list.setRowHeight(70); 
    _list.setCallback(this); 
    //mainManager.add(subManager); 
    add(subManager); 


    listElements.removeAllElements(); 
    _connectionthread = new Connection(); 
    _connectionthread.start(); 
    } 
      /*RssFileReading in a Seperate Thread*/ 
    private class Connection extends Thread { 
    public Connection() { 
    super(); 
    } 
    public void run() { 
    Document doc; 
    StreamConnection conn = null; 
    InputStream is = null; 
    try { 
    conn = (StreamConnection) Connector .open("http://toucheradio.com/toneradio/android/toriLite/toriplaylist.xml" 
     + ";deviceside=true"); 
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory 
     .newInstance(); 
    docBuilderFactory.setIgnoringElementContentWhitespace(true); 
    docBuilderFactory.setCoalescing(true); 
    DocumentBuilder docBuilder = docBuilderFactory 
     .newDocumentBuilder(); 
    docBuilder.isValidating(); 
    is = conn.openInputStream(); 
    doc = docBuilder.parse(is); 
    doc.getDocumentElement().normalize(); 
    NodeList listImg = doc.getElementsByTagName("title"); 
    for (int i = 0; i < listImg.getLength(); i++) { 
    Node textNode = listImg.item(i).getFirstChild(); 
    listElements.addElement(textNode.getNodeValue()); 
    } 
    NodeList list = doc.getElementsByTagName("image"); 
    for (int a = 0; a < list.getLength(); a++) { 
    Node textNode1 = list.item(a).getFirstChild(); 
    String imageurl = textNode1.getNodeValue(); 
    Bitmap image = GetImage.connectServerForImage(imageurl 
     .trim() + ";deviceside=true"); 
    listImage.addElement(image); 
    } 
     } catch (Exception e) { 
    System.out.println(e.toString()); 
    } finally { 
    if (is != null) { 
    try { 
     is.close(); 
    } catch (IOException ignored) { 
    } 
    } 
    if (conn != null) { 
    try { 
     conn.close(); 
    } catch (IOException ignored) { 
    } 
    } 
    } 
    UiApplication.getUiApplication().invokeLater(new Runnable() { 
    public void run() { 
    _list.setSize(listElements.size()); 
    subManager.add(_list); 
    invalidate(); 
    } 
    }); 
    } } 
/*This Method is Invoked for Each title on RssFile*/ 
public void drawListRow(ListField list, Graphics g, int index, int y, 
    int width) { 
    String title = (String) listElements.elementAt(index); 
    Bitmap image = (Bitmap) listImage.elementAt(index); 
    try { 

    g.drawBitmap(xpos, ypos, w, h, image, 0, 0); 
    xpos = w + 20; 
    g.drawText(title, xpos, ypos); 
    } catch (Exception e) { 
    e.printStackTrace(); 
    } 
    } 
} 
+0

它在模拟器的工作给予? – Signare 2013-02-23 06:51:41

+0

是在模拟器上完美工作 – String 2013-02-23 06:59:35

+0

我在设备上调试错误信息是APN未指定 – String 2013-02-23 07:00:26

回答

2

从上面的评论,清楚的是问题出在连接字符串上。在URL的末尾添加http连接字符串并尝试。

conn = (StreamConnection) Connector .open("http://toucheradio.com/toneradio/android/toriLite/toriplaylist.xml" 
    +getConnectionString()); 

getConnectionString()是如下─

private static String getConnectionString() 
{ 
    String connectionString = null; 
    // Wifi is the preferred transmission method 
    f(WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) 
    { 
     connectionString = ";interface=wifi"; 
    } 
    // Is the carrier network the only way to connect? 
    else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) 
    { 
     String carrierUid = getCarrierBIBSUid(); 
     if(carrierUid == null) 
     { 
      // Has carrier coverage, but not BIBS. So use the carrier's TCP network 
      connectionString = ";deviceside=true"; 
     } 
     else 
     { 
      // otherwise, use the Uid to construct a valid carrier BIBS request 
      connectionString = ";deviceside=false;connectionUID="+carrierUid + ";ConnectionType=mds-public"; 
     } 
    } 
    // Check for an BIS connection 
    else if (TransportInfo.isTransportTypeAvailable(TransportInfo.TRANSPORT_BIS_B) && TransportInfo.hasSufficientCoverage(TransportInfo.TRANSPORT_BIS_B)) { 
     connectionString = ";deviceside=false;ConnectionType=mds-public"; 
    } 
    // Check for an MDS connection instead (BlackBerry Enterprise Server) 
    else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) 
    { 
     connectionString = ";deviceside=false"; 
    } 
    // If there is no connection available abort to avoid bugging the user unnecssarily. 
    else if(CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE) 
    { 
     //no connection available 
    } 
    // In theory, all bases are covered so this shouldn't be reachable. 
    else 
    { 
     connectionString = ";deviceside=true"; 
    } 
    return connectionString; 
} 

/** 
* Looks through the phone's service book for a carrier provided BIBS network 
* @return The uid used to connect to that network. 
*/ 
private static String getCarrierBIBSUid() 
{ 
    ServiceRecord[] records = ServiceBook.getSB().getRecords(); 
    int currentRecord; 
    for(currentRecord = 0; currentRecord < records.length; currentRecord++) 
    {    
     if(records[currentRecord].getCid().toLowerCase().equals("ippp")) 
     {     
      if(records[currentRecord].getName().toLowerCase().indexOf("bibs") >= 0) 
      { 
       return records[currentRecord].getUid(); 
      } 
     } 
    } 
    return null; 
}