簡體   English   中英

Parse.com-解析long的值,而不是名稱/標題

[英]Parse.com - Parsing the value of a long instead of the name/title

我正在嘗試發送long的值(在這種情況下為long mStartTX),但是每次嘗試發送時,long的標題/名稱(mStartTX)都會出現在我的數據瀏覽器中,而不是long所代表的數據(自應用啟動以來使用的數據總字節數)

如何糾正這個問題,使long表示的值出現在parse.com中? 我敢肯定這很簡單。 我似乎無法使用以下方法發送所需的數據:

   testObject.put("time", Long.valueOf(mStartTX));

來源:

public class ParseStarterProjectActivity extends Activity {
TextView textSsid, textSpeed, textRssi;

public Handler mHandler = new Handler();
public long mStartRX = 0;
public long mStartTX = 0;


/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.parser);
textSsid = (TextView) findViewById(R.id.Ssid);
textSpeed = (TextView) findViewById(R.id.Speed);
textRssi = (TextView) findViewById(R.id.Rssi);
Long.toString(mStartTX);
ParseAnalytics.trackAppOpened(getIntent());
ParseObject testObject = new ParseObject("TestObject");
testObject.put("time", Long.valueOf(mStartTX));
testObject.saveInBackground();


mStartRX = TrafficStats.getTotalRxBytes();
mStartTX = TrafficStats.getTotalTxBytes();
if (mStartRX == TrafficStats.UNSUPPORTED || mStartTX == TrafficStats.UNSUPPORTED)     AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Uh Oh!");
alert.setMessage("Your device does not support traffic stat monitoring.");
alert.show();
} else {
mHandler.postDelayed(mRunnable, 1000);
}
}
private final Runnable mRunnable = new Runnable() {
public void run() {
TextView RX = (TextView)findViewById(R.id.RX);
TextView TX = (TextView)findViewById(R.id.TX);
long rxBytes = TrafficStats.getTotalRxBytes()- mStartRX;
RX.setText(Long.toString(rxBytes));
long txBytes = TrafficStats.getTotalTxBytes()- mStartTX;
TX.setText(Long.toString(txBytes));
mHandler.postDelayed(mRunnable, 1000);

難怪, "mStartTX"是一個String文字,而mStartTX是一個long類型的變量。 使用不帶引號的mStartTX ,如果該方法不接受long作為參數,請使用Long.toString(mStartTX) ,然后使用Long.valueOf(mStartTXStr)對其進行解析。 希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM