<NOTICE> I mean ADD, so check the format in your exist codes.
general speaking:
step 1. In MainActivity.java: launch probes in your service pool
runOnceIntent.putExtra(MainPipeline.RUN_ONCE_PROBE_NAME, <your probe>.class.getName());
startService(runOnceIntent);
step 2. In Assets/default.json: set configuration of your probe
"edu.mit.media.funf.probe.<your probe>": [
{ }
],
step 3. In Manifest : set up your services:
<service android:name="edu.mit.media.funf.probe.<your probe>"></service>
step 4. In Manifest : add the permission your probes need
<uses-permission android:name="android.permission.<permission your probe need>" />
-----------------------------
Example: add BatteryProbe
1. In MainActivity.java
Button scanNowButton = (Button)findViewById(R.id.scanNowButton);
scanNowButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent runOnceIntent = new Intent(context, MainPipeline.class);
runOnceIntent.setAction(MainPipeline.ACTION_RUN_ONCE);
runOnceIntent.putExtra(MainPipeline.RUN_ONCE_PROBE_NAME, WifiProbe.class.getName());
startService(runOnceIntent);
runOnceIntent.putExtra(MainPipeline.RUN_ONCE_PROBE_NAME, LocationProbe.class.getName());
startService(runOnceIntent);
runOnceIntent.putExtra(MainPipeline.RUN_ONCE_PROBE_NAME, BatteryProbe.class.getName());
startService(runOnceIntent);
}
});
}
step 2. In Assets/default.json
{ "name": "WifiScanner",
"version":1,
"dataArchivePeriod":3600,
"dataRequests":{
"edu.mit.media.funf.probe.builtin.LocationProbe": [
{ "PERIOD": 900, "DURATION": 30 }
],
"edu.mit.media.funf.probe.builtin.WifiProbe": [
{ "PERIOD": 900 }
],
"edu.mit.media.funf.probe.builtin.BatteryProbe": [
{ }
]
}
}
step3. In Manifest : set up your services
<service android:name="edu.mit.media.funf.probe.builtin.LocationProbe"></service>
<service android:name="edu.mit.media.funf.probe.builtin.WifiProbe"></service>
<service android:name="edu.mit.media.funf.probe.builtin.BatteryProbe"></service>
step4. In Manifest : add the permission your probes need
<uses-permission android:name="android.permission.BATTERY_STATS" />
<!-- All probes -->
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- Location probe -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Wifi probe -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
----------------
hint: Why I add that permission? check here: Funf wiki
Imps are always mischievous, uncontrollable, only obedient to somebody special, and not as powerful as the real demons, yet.
小惡魔:調皮難控制的猴小孩,還在努力成為真正的大惡魔中。
As the title suggests, this is my everything notebook, may in traditional Chinese or English.
這裡什麼都寫,不管是食譜、遊記、練習寫作的爛文,抑或是個人的一些狗屁倒灶的東西都有可能出現,使用語言也是隨性。
*Sometimes, those bilingual articles are not formed by translation, I will represent the concepts twice using different ways of thinking based on the language I use.
Wednesday, March 21, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment