There are four steps to make your application context aware with MSF.
First, you need to download the jars.zip file from the site and extract it into your application's libs folder. The eclipse/android studio will do the rest.
You have to change this line in your application:
public class MyActivity extends Activity {
to this:
public class MyActivity extends MsfActivity {
Now you can use the MSF. (You also can use MsfFragment and MsfFragmentActivity to reach the MSF specific functions.)
You have to create your own configuration with a new msfConfig.xml file in your assets folder. Read more about this here: [MSF XML Configuration]
In the last step you need to modify your project's AndroidManifest.xml file. For more details check this site: [Modify the AndroidManifest.xml File]
Within an MsfActivity class you can start and stop the event listening anytime.
For the start you need to call one of these methods:
startEventListenerService("Event listening", "Looking for events...",
R.drawable.icon, R.drawable.icon_ok, R.drawable.icon_error);
//or
startEventListenerService();
With the first one you will create a foreground service with a specific notification. The first two parameters are the title and the text of the notification, the third one is the id of the notification's main icon. The last two parameters are the "Service successfully started" and the "Error occurred" notification's icons.
The second one will also create a foreground service, but in that case, there won't be any notification. This is a silent mode.
To stop the service you can use this method:
stopEventListenerService();
The MSF is running in the background, once you started the service, the service is automatically looking for events, and if it occurs, the MSF will store it in the database immediately.
To reach the already collected events you need to use the main (and singleton) MsfDao object.
You can get this object from every MsfActivity, MsfFragmentActivity and MsfFragment class with the following line:
MsfDao dao = getMsfDao();
For more information about the available functions in the MsfDao class visit this page: [MSF DAO class]
The MSF also provides you a special network manager class, where you can easily upload a file or post data to a server or download a webpage content. You can reach this class with this line from any MSF context:
MsfNetworkManager msfNetworkManager = getMsfNetworkManager();
For more information check this page: [MSF Network Manager]
With the MSF your application also get a very powerful location based notification mechanism. For this we provide an MsfNotificationManager class, what you can reach with the following code:
MsfNotificationManager msfNotificationManager = getMsfNotificationManager();
For more information about the location based notifications and the available functions in the MsfNotificationManager class visit this page: [Location Based Notifications]
You can create snapshots or backups about the current state of the events and self reports. This backup is more lasting than a database entries, because this backup will save every event and self report information on the phone's external storage (The data won't be removed if the user removes the application).
The created files are standard CSV files on the external storage's msfBackup folder. The file contains every necessary information in its header, so it's already prepared for analyzing.
You can start a backup service with the following code:
registerBackupService(Calendar.getInstance(), ONE_DAY_IN_MILLIS);
//or
registerBackupService();
/* Equals with this:
final Calendar cal = new GregorianCalendar();
cal.set(Calendar.YEAR, 2013);
cal.set(Calendar.DAY_OF_YEAR, 1);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
registerBackupService(context, cal, ONE_DAY_IN_MILLIS);
*/
With the first one you can set up the backups. The first parameter is the initial time, and the second one is the time interval between two backups.
The second option will create daily backup at midnight.
For more information about the available functions and the backup mechanism visit this page: [Automatic Backup and Upload Mechanism]
With the MSF you can obtain very easily a lot of information about the user and the phone. You can get for example the main email address of the user, or the phone unique ID. For more information visit this page: [MSF Utils]
Wiki: Home
Wiki: MSF XML Configuration
Wiki: Modify the AndroidManifest.xml File