2013-07-20 1 views
0

Pourquoi puis-je obtenir un « débordement de pile sur appel à Ljava/util/WeakHashMap » erreur lorsque xstream convertit le ShootRecord en XML?débordement de pile sur appel à WeakHashMap lors de l'utilisation xstream dans l'application Android

champs de classe ShootRecord et constructeur

public class ShootRecord /* implements Serializable */ 
{ 
    private String mShootRecordName = ""; 
    private String mShootRecordDate = ""; 
    private int mNumArchersOnTarget; 
    private int mScoreSheetTypeIndex; 

private Bitmap mScoreSheetBackground = null; 

private ArrayList<ScoreSheet> mListOfScoreSheets = new ArrayList<ScoreSheet>(); 
private int mActiveScoreSheetIndex = 0; 

private ScoreSheetsView mScoreSheetsView; 

/** 
* Constructs a new ShootRecord object. 
* @param scoreSheetsView Reference to the score sheet rendering View. 
* @param name The name string for the shoot record. 
* @param date The date string for the shoot record. 
* @param archers The number of archers on the shoot record. 
* @param sheetType The score sheet type index for the shoot record. 
*/ 
public ShootRecord(ScoreSheetsView scoreSheetsView, String name, String date, int archers, int sheetType) 
{ 
    mScoreSheetsView = scoreSheetsView; 

    mShootRecordName = name; 
    mShootRecordDate = date; 
    mNumArchersOnTarget = archers; 
    mScoreSheetTypeIndex = sheetType; 
} 

MainActivity définition de classe:

public class MainActivity extends Activity implements View.OnTouchListener

constructeur de la classe FileSender:

public FileSender(Activity activity) 
    { 
     mMainActivity = (MainActivity) activity; 
    } 

Méthode FileSender:

public boolean postToServletOverWifi(ShootRecord recToSend, Context context){

try{ 

     /* prepare object as xml */ 
     XStream xstream = new XStream(); 

     /* make outputting of xml more concise (optional)*/ 
     xstream.alias("ShootRecord", ShootRecord.class); 

     String xml = xstream.toXML(recToSend); /* convert object to xml */ 

     WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); 
     wifiManager.startScan(); 
     List<ScanResult> list = wifiManager.getScanResults(); 
     for(ScanResult i : list) { 

      /* list network name/ssid */ 
      i.describeContents(); 
     } 

      /* get user selected wifi network 
      /* selectedNetwork = ??? selection from list 

      if(selectedNetwork.SSID != null && selectedNetwork.SSID.equals("\"" + networkSSID + "\"")) { 
       wifiManager.disconnect(); 
       wifiManager.enableNetwork(selectedNetwork.SSID, true); 
       wifiManager.reconnect();     
       break; 
      }  
      */ 

     /* Create WifiConfiguration instance: 
      WifiConfiguration conf = new WifiConfiguration(); 
     conf.SSID = "\"" + networkSSID + "\""; // string should contain ssid in quotes 
        conf.preSharedKey = "\""+ networkPass +"\""; 
        wifiManager.addNetwork(conf); 


     HttpClient client = new DefaultHttpClient(); 
     HttpPost post = new HttpPost("http://" + server + "/Archery"); 
     post.setHeader("Content-type", "text/xml;charset=utf-8"); 



some call to post xml?? 
*/ 

} catch (Exception e){ 
      System.out.println(e.getMessage()); 
      e.printStackTrace(); 
      return false; 

} 

} //end method 

Appel à la méthode:

public void promptUserToSendShootRecord(ShootRecord recToSend) {

final ShootRecord shootRecord = recToSend; 

    createIntentToSendZippedRecord(shootRecord); //this method works 
    postToServletOverWifi(shootRecord, mMainActivity.mContext); 
} 

catlog

+0

en mettant des appels de log dans mon code, ive établi que l'appel de convertir en xml est l'appel qui déborde de la pile ... – jsky

Répondre

Questions connexes