add json null for making sdk requests. cleanup notifications on service shutdown.
This commit is contained in:
parent
6b8b227af7
commit
e80815cf7e
3 changed files with 18 additions and 6 deletions
|
@ -8,6 +8,7 @@ import android.content.Intent;
|
|||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.os.Process;
|
||||
import java.io.File;
|
||||
|
@ -126,9 +127,16 @@ public class PythonService extends Service implements Runnable {
|
|||
serviceEntrypoint, pythonName,
|
||||
pythonHome, pythonPath,
|
||||
pythonServiceArgument);
|
||||
cleanupNotifications();
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
public void cleanupNotifications() {
|
||||
Context context = getApplicationContext();
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.cancelAll();
|
||||
}
|
||||
|
||||
// Native part
|
||||
public static native void nativeStart(
|
||||
String androidPrivate, String androidArgument,
|
||||
|
|
|
@ -481,6 +481,14 @@ public final class LbrynetService extends PythonService {
|
|||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupNotifications() {
|
||||
Context context = getApplicationContext();
|
||||
NotificationManager notificationManager =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.cancelAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (downloadReceiver != null) {
|
||||
|
@ -493,11 +501,7 @@ public final class LbrynetService extends PythonService {
|
|||
stopServiceReceiver = null;
|
||||
}
|
||||
|
||||
Context context = getApplicationContext();
|
||||
NotificationManager notificationManager =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.cancelAll();
|
||||
|
||||
cleanupNotifications();
|
||||
super.onDestroy();
|
||||
serviceInstance = null;
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ public final class Utils {
|
|||
if (params != null) {
|
||||
JSONObject requestParams = new JSONObject();
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
requestParams.put(entry.getKey(), entry.getValue());
|
||||
requestParams.put(entry.getKey(), entry.getValue() == null ? JSONObject.NULL : entry.getValue());
|
||||
}
|
||||
request.put("params", requestParams);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue