gpt4 book ai didi

java - BlackBerry RSS Feed 未在设备上加载

转载 作者:行者123 更新时间:2023-12-02 07:15:05 31 4
gpt4 key购买 nike

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

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

谁能告诉我出了什么问题吗?

注意:当我在真实设备上运行该应用程序时,屏幕上会显示* Feeds 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();
}
}
}

最佳答案

从上面的评论中,很明显问题出在连接字符串上。在 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;
}

关于java - BlackBerry RSS Feed 未在设备上加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15037836/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com