Fix logging of background task

This commit is contained in:
Mieszko Wrzeszczyński 2018-09-30 10:06:20 +02:00
parent b591587e6a
commit c9bb9cbf95
3 changed files with 21 additions and 23 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.uam.wmi.findmytutor"> package="com.uam.wmi.findmytutor">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
@ -13,12 +14,16 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<receiver android:name=".utils.BroadcastLocalizationHandler"> <receiver android:name=".utils.BroadcastLocalizationHandler"
android:enabled="true"
android:exported="false"
>
<intent-filter> <intent-filter>
<action android:name="com.uam.wmi.findmytutor"> <action android:name="background.location.broadcast">
</action> </action>
</intent-filter> </intent-filter>
</receiver> </receiver>

View File

@ -37,6 +37,7 @@ import com.mapbox.mapboxsdk.Mapbox;
import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.service.LdapService; import com.uam.wmi.findmytutor.service.LdapService;
import com.uam.wmi.findmytutor.service.LocationService; import com.uam.wmi.findmytutor.service.LocationService;
import com.uam.wmi.findmytutor.utils.BroadcastLocalizationHandler;
import com.uam.wmi.findmytutor.utils.PrefUtils; import com.uam.wmi.findmytutor.utils.PrefUtils;
import org.reactivestreams.Subscriber; import org.reactivestreams.Subscriber;
@ -142,18 +143,7 @@ public class MainActivity extends AppCompatActivity {
this.broadcastReceiver = new BroadcastReceiver() { this.broadcastReceiver = new BroadcastLocalizationHandler();
@Override
public void onReceive(Context context, Intent intent) {
latitude = intent.getDoubleExtra("latitude",0);
longitude = intent.getDoubleExtra("longitude",0);
Log.e("Background service", String.valueOf(latitude));
}
};
//You should find out what causes this fancy/not reproducible error //You should find out what causes this fancy/not reproducible error
/* Coordinate coordinate = new Coordinate(latitude); /* Coordinate coordinate = new Coordinate(latitude);

View File

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
public class BroadcastLocalizationHandler extends BroadcastReceiver { public class BroadcastLocalizationHandler extends BroadcastReceiver {
public static String str_receiver = "servicetutorial.service.receiver"; public static String str_receiver = "servicetutorial.service.receiver";
@ -14,11 +15,13 @@ public class BroadcastLocalizationHandler extends BroadcastReceiver {
@Override @Override
public void onReceive(Context arg0, Intent arg1) { public void onReceive(Context arg0, Intent intent) {
//tutaj operujemy na naszym powiadomieniu, dane które zostały nam przekazane wyciągamy z parametru arg1. Double latitude, longitude;
latitude = intent.getDoubleExtra("latitude", 0);
// longitude = intent.getDoubleExtra("longitude",0);
Log.e("Background service", String.valueOf(latitude));
} }
} }