我已經創建了由我希望各國財長將保存到我的遠程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