Skip to content

Instantly share code, notes, and snippets.

Avatar

Rafal Woloszyn rwoloszyn

View GitHub Profile
View MonitorActivity.java
private void readLogs() {
logger.debug("Enter");
BufferedReader logReader = null;
try {
String line = null;
File log = getLogFile();
logReader = new BufferedReader(new FileReader(log));
while ((line = logReader.readLine()) != null) {
View MonitorActivity.java
logger.error("msg={}", e.getMessage());
@rwoloszyn
rwoloszyn / AndroidApplication.java
Last active Apr 6, 2016
Register broadcastreceiver if debug
View AndroidApplication.java
/**
* Test broadcast receiver used only for debug
*/
private BroadcastReceiver testTransitStateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
logger.debug("Entry");
Log.d("SomeReceiver", "testTransitStateReceiver");
if(TEST_ACTION.equals(intent.getAction())){
String extras = intent.getStringExtra("state");
@rwoloszyn
rwoloszyn / SomeActivity.java
Created Mar 8, 2016
Check if service is running
View SomeActivity.java
private boolean isMyServiceRunning(Class<?> serviceClass) {
logger.debug("serviceClass={}", serviceClass);
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
@rwoloszyn
rwoloszyn / JavaIO.java
Created Mar 7, 2016
Get file extensions in Java using Apache I/O
View JavaIO.java
//If file is compressed uncompress it
if(FilenameUtils.getExtension(file.getAbsolutePath())
.equals("zip")){
logger.debug("file={}, unzipping",
file.getAbsolutePath());
}
@rwoloszyn
rwoloszyn / ContentDesc.java
Created Nov 4, 2015
SMS Content description columns
View ContentDesc.java
Those are values for android 4.4.4 in S3 for Smasung S3.
V/ActivityManager$SmsObserver(17187): .onChange: SMS Send !!! timestamp: 1446649046654
V/ActivityManager$SmsObserver(17187): .onChange: _id and its value: 211
V/ActivityManager$SmsObserver(17187): .onChange: thread_id and its value: 7
V/ActivityManager$SmsObserver(17187): .onChange: address and its value: +48692631872
V/ActivityManager$SmsObserver(17187): .onChange: person and its value: null
V/ActivityManager$SmsObserver(17187): .onChange: date and its value: 1446649046654
V/ActivityManager$SmsObserver(17187): .onChange: date_sent and its value: 1446649022000
V/ActivityManager$SmsObserver(17187): .onChange: protocol and its value: 0