我已经创建了由我希望各国财长将保存到我的远程server.Thanks提前如何将FUNF探针保存到远程服务器?
公共类只使用基本的探头就像wifi和简单location.At数据保存到SD卡的那一刻起funf应用MainActivity扩展活动实现的DataListener {
public static final String PIPELINE_NAME = "default";
private FunfManager funfManager;
private BasicPipeline pipeline;
private WifiProbe wifiProbe;
private SimpleLocationProbe locationProbe;
private CheckBox enabledCheckbox;
private Button archiveButton, scanNowButton;
private TextView dataCountView;
private Handler handler;
private ServiceConnection funfManagerConn = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
funfManager = ((FunfManager.LocalBinder)service).getManager();
Gson gson = funfManager.getGson();
wifiProbe = gson.fromJson(new JsonObject(), WifiProbe.class);
locationProbe = gson.fromJson(new JsonObject(), SimpleLocationProbe.class);
pipeline = (BasicPipeline) funfManager.getRegisteredPipeline(PIPELINE_NAME);
wifiProbe.registerPassiveListener(MainActivity.this);
locationProbe.registerPassiveListener(MainActivity.this);
// This checkbox enables or disables the pipeline
enabledCheckbox.setChecked(pipeline.isEnabled());
enabledCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (funfManager != null) {
if (isChecked) {
funfManager.enablePipeline(PIPELINE_NAME);
pipeline = (BasicPipeline) funfManager.getRegisteredPipeline(PIPELINE_NAME);
} else {
funfManager.disablePipeline(PIPELINE_NAME);
}
}
}
});
// Set UI ready to use, by enabling buttons
enabledCheckbox.setEnabled(true);
archiveButton.setEnabled(true);
scanNowButton.setEnabled(true);
}
@Override
public void onServiceDisconnected(ComponentName name) {
// TODO Auto-generated method stub
funfManager = null;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Forces the pipeline to scan now
scanNowButton = (Button) findViewById(R.id.scanNowButton);
scanNowButton.setEnabled(false);
scanNowButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (pipeline.isEnabled()) {
// Manually register the pipeline
wifiProbe.registerListener(pipeline);
locationProbe.registerListener(pipeline);
} else {
Toast.makeText(getBaseContext(), "Pipeline is not enabled.", Toast.LENGTH_SHORT).show();
}
}
});
// Displays the count of rows in the data
dataCountView = (TextView) findViewById(R.id.dataCountText);
// Used to make interface changes on main thread
handler = new Handler();
enabledCheckbox = (CheckBox) findViewById(R.id.enabledCheckbox);
enabledCheckbox.setEnabled(false);
// Runs an archive if pipeline is enabled
archiveButton = (Button) findViewById(R.id.archiveButton);
archiveButton.setEnabled(false);
archiveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (pipeline.isEnabled()) {
pipeline.onRun(BasicPipeline.ACTION_ARCHIVE, null);
// Wait 1 second for archive to finish, then refresh the UI
// (Note: this is kind of a hack since archiving is seamless and there are no messages when it occurs)
handler.postDelayed(new Runnable() {
@Override
public void run() {
Toast.makeText(getBaseContext(), "Archived!", Toast.LENGTH_SHORT).show();
updateScanCount();
}
}, 1000L);
} else {
Toast.makeText(getBaseContext(), "Pipeline is not enabled.", Toast.LENGTH_SHORT).show();
}
}
});
// Bind to the service, to create the connection with FunfManager
bindService(new Intent(this, FunfManager.class), funfManagerConn, BIND_AUTO_CREATE);
}
@Override
public void onDataCompleted(IJsonObject probeConfig, JsonElement checkpoint) {
updateScanCount();
// Re-register to keep listening after probe completes.
wifiProbe.registerPassiveListener(this);
locationProbe.registerPassiveListener(this);
}
@Override
public void onDataReceived(IJsonObject arg0, IJsonObject arg1) {
// TODO Auto-generated method stub
}
private static final String TOTAL_COUNT_SQL = "SELECT count(*) FROM " + NameValueDatabaseHelper.DATA_TABLE.name;
/**
* Queries the database of the pipeline to determine how many rows of data we have recorded so far.
*/
private void updateScanCount() {
// Query the pipeline db for the count of rows in the data table
SQLiteDatabase db = pipeline.getDb();
Cursor mcursor = db.rawQuery(TOTAL_COUNT_SQL, null);
mcursor.moveToFirst();
final int count = mcursor.getInt(0);
// Update interface on main thread
runOnUiThread(new Runnable() {
@Override
public void run() {
dataCountView.setText("Data Count: " + count);
}
});
}
}
如果我创建数据库我怎么知道我的领域,并再次在那里把后端功能 – walters 2014-10-01 14:11:08
你什么意思,你怎么会知道你的领域?例如,您应该编写PHP函数来调用它,以打开数据库,并在数据中插入一行。然后从android发送HTTPRequest(或POST),并使用应用程序中的数据调用该函数。 PHP函数获取您发送的数据,并在一切正常时返回响应。 – 2014-10-01 16:29:51
Hi @walters Hi,你有答案吗?如果没有请平安我,我可以帮助你。 – vipin 2014-10-22 12:18:40