[英]Parse.com - Parsing the value of a long instead of the name/title
I'm attempting to send the value of a long (in this case the long mStartTX) however each time I attempt to do so the title/name of the long (mStartTX) appears in my data browser instead of the data the long represents (total bytes of data used since the app launched) 我正在尝试发送long的值(在这种情况下为long mStartTX),但是每次尝试发送时,long的标题/名称(mStartTX)都会出现在我的数据浏览器中,而不是long所代表的数据(自应用启动以来使用的数据总字节数)
How can this be corrected so the value the long represents appears in parse.com? 如何纠正这个问题,使long表示的值出现在parse.com中? I'm sure this is very simple.
我敢肯定这很简单。 I simply cannot seem to send the data I need using the method below:
我似乎无法使用以下方法发送所需的数据:
testObject.put("time", Long.valueOf(mStartTX));
FULL SOURCE: 来源:
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);
There's no wonder, "mStartTX"
is a String
literal, and mStartTX
is a variable of type long
. 难怪,
"mStartTX"
是一个String
文字,而mStartTX
是一个long
类型的变量。 Use mStartTX
without quotes, and in case the method doesn't accept long as a parameter, use Long.toString(mStartTX)
and then parse it using Long.valueOf(mStartTXStr)
. 使用不带引号的
mStartTX
,如果该方法不接受long作为参数,请使用Long.toString(mStartTX)
,然后使用Long.valueOf(mStartTXStr)
对其进行解析。 Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.