-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from GeoTecINIT/inject-service
Recording service injection
- Loading branch information
Showing
4 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ossensors/src/main/java/es/uji/geotec/wearossensors/services/RecordingServiceManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package es.uji.geotec.wearossensors.services; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
public class RecordingServiceManager { | ||
|
||
private static final String PREFERENCES_NAME = "WEAROSSENSORS_PREFS"; | ||
private static final String RECORDING_SERVICE_KEY = "RECORDING_SERVICE"; | ||
|
||
public static void setService(Context context, Class<?> permissionsActivity) { | ||
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE); | ||
SharedPreferences.Editor editor = preferences.edit(); | ||
editor.putString(RECORDING_SERVICE_KEY, permissionsActivity.getName()); | ||
editor.apply(); | ||
} | ||
|
||
public static Class<?> getService(Context context) { | ||
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE); | ||
String className = preferences.getString(RECORDING_SERVICE_KEY, WearSensorRecordingService.class.getName()); | ||
|
||
Class<?> permissionsActivityClass = null; | ||
try { | ||
permissionsActivityClass = Class.forName(className); | ||
} catch (ClassNotFoundException e) { | ||
e.printStackTrace(); | ||
} | ||
return permissionsActivityClass; | ||
} | ||
} |