Java 设备上未加载BlackBerry RSS源

Java 设备上未加载BlackBerry RSS源,java,blackberry,java-me,Java,Blackberry,Java Me,我已经开发了RSS提要阅读器应用程序,当我在BB Simulator 9900上执行该应用程序时,我能够成功地显示列表项 但是当我尝试在我的真实设备BB Curve 9380上执行相同的应用程序时,我无法加载我的列表项 谁能告诉我出了什么问题 注意:当我在真实设备上运行应用程序时,屏幕上会显示*feed Not Available*消息 这是我的代码: public class RssScreen extends MainScreen implements ListFieldCallback {

我已经开发了RSS提要阅读器应用程序,当我在BB Simulator 9900上执行该应用程序时,我能够成功地显示列表项

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

谁能告诉我出了什么问题

注意:当我在真实设备上运行应用程序时,屏幕上会显示*feed Not Available*消息

这是我的代码:

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();
    }
    }
 }
公共类RssScreen扩展MainScreen实现ListFieldCallback{
公共RssScreen(){
subManager=新建垂直字段管理器(Manager.VERTICAL\u滚动
|管理器。垂直(滚动条){
受保护的空位子布局(int-maxWidth、int-maxHeight){
int displayWidth=Display.getWidth();
int displayHeight=Display.getHeight();
超级子布局(显示宽度、显示高度);
setExtent(显示宽度、显示高度);
}
};
_列表=新列表字段()
{
受保护的布尔导航单击(int状态,int时间){
返回true;
}
公共空间绘制(图形)
{
graphics.setColor((int)mycolor);
超级油漆(图形);
}
};
mycolor=0x00FFFFFF;
_list.invalidate();
_list.setEmptyString(“*提要不可用*”,DrawStyle.HCENTER);
_列表。设置行高(70);
_list.setCallback(this);
//mainManager.add(子管理器);
添加(子管理器);
listElements.removeAllElements();
_connectionthread=新连接();
_connectionthread.start();
}
/*RssFileReading在一个单独的线程中*/
私有类连接扩展线程{
公共连接(){
超级();
}
公开募捐{
文件文件;
StreamConnection conn=null;
InputStream=null;
试一试{
连接=(流连接)连接器。打开(“http://toucheradio.com/toneradio/android/toriLite/toriplaylist.xml"
+“deviceside=true”);
DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory
.newInstance();
setIgnoringElementContentWhitespace(true);
docBuilderFactory.setCoalescing(true);
DocumentBuilder docBuilder=docBuilderFactory
.newDocumentBuilder();
isValidating();
is=conn.openInputStream();
doc=docBuilder.parse(is);
doc.getDocumentElement().normalize();
节点列表img=doc.getElementsByTagName(“标题”);
对于(int i=0;i
从上面的注释中,很明显问题出在连接字符串上。在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;
} 
private静态字符串getConnectionString()
{
字符串连接字符串=null;
//Wifi是首选的传输方式
f(WLANInfo.getWLANState()==WLANInfo.WLAN\u状态\u已连接)
{
connectionString=“;接口=wifi”;
}
//运营商网络是唯一的连接方式吗?
else if((CoverageInfo.getcoveragentatus()&CoverageInfo.COVERAGE\u DIRECT)==CoverageInfo.COVERAGE\u DIRECT)
{
字符串carrierUid=getCarrierBIBSUid();
if(carrierUid==null)
{
//有运营商的覆盖范围,但没有BIB。所以使用运营商的TCP网络
connectionString=“;deviceside=true”;
}
其他的
{
//否则,使用Uid构造有效的承运人BIBS请求
connectionString=“;deviceside=false;connectionUID=“+carrierUid+”;ConnectionType=mds public”;
}
}
//检查BIS连接
else if(TransportInfo.isTransportTypeAvailable(TransportInfo.TRANSPORT\u BIS\u B)和&TransportInfo.HasufficientCoverage(TransportInfo.TRANSPORT\u BIS\u B)){
connectionString=“;deviceside=false;ConnectionType=mds public”;
}
//改为检查MDS连接(BlackBerry Enterprise Server)
else if((CoverageInfo.getcoveragentatus()&CoverageInfo.COVERAGE\u MDS)==CoverageInfo.COVERAGE\u MDS)
{
connectionString=“;deviceside=false”;
}
//如果没有可用的连接,请中止以避免不必要地窃听用户。
else if(CoverageInfo.getcoveragentatus()==CoverageInfo.COVERAGE\u NONE)
{
//没有可用的连接
}
//理论上,所有的基础都被覆盖了,所以这是不可能实现的。
其他的
{
connectionString=“;deviceside=true”;
}
返回连接字符串;
}
/**
*查看手机的服务手册,查找运营商提供的BIBS网络
*@返回用于连接到该网络的uid。
*/
私有静态字符串getCarrierBIB