我正在尝试发送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);
答案 0 :(得分:0)
毫无疑问,"mStartTX"
是String
字面值,mStartTX
是long
类型的变量。使用不带引号的mStartTX
,如果方法不接受长参数,请使用Long.toString(mStartTX)
,然后使用Long.valueOf(mStartTXStr)
对其进行解析。希望这会有所帮助。