繁体   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