current revision
This commit is contained in:
@@ -7,10 +7,18 @@ public class MyActivity extends QtActivity {
|
||||
|
||||
public static MyActivity act;
|
||||
|
||||
// IPIN2016
|
||||
private StepLoggerClient stepLogger;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedState) {
|
||||
MyActivity.act = this;
|
||||
super.onCreate(savedState);
|
||||
|
||||
// IPIN2016
|
||||
stepLogger = new StepLoggerClient(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
79
_android/src/StepLoggerClient.java
Normal file
79
_android/src/StepLoggerClient.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package indoor.java;
|
||||
|
||||
import android.app.IntentService;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.Context;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import it.cnr.isti.steplogger.IStepLoggerService;
|
||||
|
||||
|
||||
/**
|
||||
* An {@link IntentService} subclass for handling asynchronous task requests in
|
||||
* a service on a separate handler thread.
|
||||
*/
|
||||
public class StepLoggerClient {
|
||||
|
||||
private static StepLoggerClient instance;
|
||||
|
||||
// Intent Service fields
|
||||
private static String LOG_TAG = "StepLoggerClient";
|
||||
private boolean mustRun = true;
|
||||
|
||||
// Bound Service fields
|
||||
final String BOUNDSERVICE_PACKAGE = "it.cnr.isti.steplogger";
|
||||
final String BOUNDSERVICE_CLASS = ".StepLoggerService";
|
||||
IStepLoggerService mService;
|
||||
|
||||
Boolean isBound = false;
|
||||
Intent intentService = new Intent();
|
||||
|
||||
//Bound Service Connection
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
|
||||
public void onServiceConnected(ComponentName name, IBinder boundService) {
|
||||
mService = IStepLoggerService.Stub.asInterface((IBinder) boundService);
|
||||
Log.d(LOG_TAG, "onServiceConnected() : OK ");
|
||||
isBound = true;
|
||||
}
|
||||
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
mService = null;
|
||||
Log.d(LOG_TAG, "onServiceDisconnected() : OK ");
|
||||
isBound = false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/** ctor */
|
||||
public StepLoggerClient(MyActivity act) {
|
||||
|
||||
instance = this;
|
||||
|
||||
intentService.setClassName(BOUNDSERVICE_PACKAGE, BOUNDSERVICE_PACKAGE + BOUNDSERVICE_CLASS);
|
||||
act.bindService(intentService, mConnection , Context.BIND_AUTO_CREATE );
|
||||
|
||||
}
|
||||
|
||||
/** static access from C++ */
|
||||
public static int log(double x, double y, double z) {
|
||||
Log.d("me", "got values");
|
||||
instance._log(x,y,z);
|
||||
return 1337; // return a magic-code that is checked within c++
|
||||
}
|
||||
|
||||
private void _log(double x, double y, double z) {
|
||||
Log.d("me", mService + "");
|
||||
if (mService == null) {return;}
|
||||
try {
|
||||
mService.logPosition(System.currentTimeMillis(), x, y, z);
|
||||
} catch (final Exception e) {;}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,13 +34,13 @@ public class WiFi {
|
||||
MyActivity act = MyActivity.act;
|
||||
manager = (WifiManager) act.getSystemService(Context.WIFI_SERVICE);
|
||||
|
||||
reset();
|
||||
// reset();
|
||||
|
||||
WiFi.receiver = new BroadcastReceiver() {
|
||||
public final void onReceive(final Context context, final Intent intent) {
|
||||
final byte[] result = serialize(manager.getScanResults());
|
||||
triggerOneScan();
|
||||
WiFi.onScanComplete(result);
|
||||
triggerOneScan();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// IMisuratoreService.aidl
|
||||
package it.cnr.isti.steplogger;
|
||||
|
||||
// Declare any non-default types here with import statements
|
||||
|
||||
interface IStepLoggerService {
|
||||
void logPosition(in long timestamp, in double x, in double y, in double z);
|
||||
}
|
||||
Reference in New Issue
Block a user