diff --git a/app/src/mobile/AndroidManifest.xml b/app/src/mobile/AndroidManifest.xml
index 1d736d4ec..a164b2042 100644
--- a/app/src/mobile/AndroidManifest.xml
+++ b/app/src/mobile/AndroidManifest.xml
@@ -136,6 +136,7 @@
android:foregroundServiceType="mediaPlayback">
+
@@ -143,11 +144,11 @@
android:name=".receiver.ActionReceiver"
android:exported="false">
-
-
-
-
-
+
+
+
+
+
diff --git a/app/src/mobile/java/com/fongmi/android/tv/event/ActionEvent.java b/app/src/mobile/java/com/fongmi/android/tv/event/ActionEvent.java
index 4d34147e6..508451b2f 100644
--- a/app/src/mobile/java/com/fongmi/android/tv/event/ActionEvent.java
+++ b/app/src/mobile/java/com/fongmi/android/tv/event/ActionEvent.java
@@ -1,17 +1,19 @@
package com.fongmi.android.tv.event;
+import com.fongmi.android.tv.BuildConfig;
+
import org.greenrobot.eventbus.EventBus;
public class ActionEvent {
- public static String PREV = "PREV";
- public static String NEXT = "NEXT";
- public static String PLAY = "PLAY";
- public static String PAUSE = "PAUSE";
- public static String UPDATE = "UPDATE";
- public static String CANCEL = "CANCEL";
+ public static String STOP = BuildConfig.APPLICATION_ID.concat(".stop");
+ public static String PREV = BuildConfig.APPLICATION_ID.concat(".prev");
+ public static String NEXT = BuildConfig.APPLICATION_ID.concat(".next");
+ public static String PLAY = BuildConfig.APPLICATION_ID.concat(".play");
+ public static String PAUSE = BuildConfig.APPLICATION_ID.concat(".pause");
+ public static String UPDATE = BuildConfig.APPLICATION_ID.concat(".update");
- private String type;
+ private final String action;
public static void send(String action) {
EventBus.getDefault().post(new ActionEvent(action));
@@ -21,11 +23,11 @@ public class ActionEvent {
EventBus.getDefault().post(new ActionEvent(UPDATE));
}
- public ActionEvent(String type) {
- this.type = type;
+ public ActionEvent(String action) {
+ this.action = action;
}
- public String getType() {
- return type;
+ public String getAction() {
+ return action;
}
}
diff --git a/app/src/mobile/java/com/fongmi/android/tv/receiver/ActionReceiver.java b/app/src/mobile/java/com/fongmi/android/tv/receiver/ActionReceiver.java
index afda40ee8..b254d8c15 100644
--- a/app/src/mobile/java/com/fongmi/android/tv/receiver/ActionReceiver.java
+++ b/app/src/mobile/java/com/fongmi/android/tv/receiver/ActionReceiver.java
@@ -2,24 +2,20 @@ package com.fongmi.android.tv.receiver;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import com.fongmi.android.tv.App;
import com.fongmi.android.tv.event.ActionEvent;
import com.fongmi.android.tv.utils.Utils;
public class ActionReceiver extends BroadcastReceiver {
- public static PendingIntent getPendingIntent(Context context, String type) {
- Intent intent = new Intent(App.get().getPackageName() + "." + type);
- intent.setComponent(new ComponentName(context, ActionReceiver.class));
- return PendingIntent.getBroadcast(context, 0, intent, Utils.getPendingFlag());
+ public static PendingIntent getPendingIntent(Context context, String action) {
+ return PendingIntent.getBroadcast(context, 100, new Intent(action).setPackage(context.getPackageName()), Utils.getPendingFlag());
}
@Override
public void onReceive(Context context, Intent intent) {
- ActionEvent.send(intent.getAction().replace(context.getPackageName() + ".", ""));
+ ActionEvent.send(intent.getAction());
}
}
diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
index 0aebcd6cf..3cae5542c 100644
--- a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
+++ b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
@@ -639,13 +639,13 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
@Subscribe(threadMode = ThreadMode.MAIN)
public void onActionEvent(ActionEvent event) {
- if (event.getType().equals(ActionEvent.PLAY) || event.getType().equals(ActionEvent.PAUSE)) {
+ if (ActionEvent.PLAY.equals(event.getAction()) || ActionEvent.PAUSE.equals(event.getAction())) {
checkPlay();
- } else if (event.getType().equals(ActionEvent.NEXT)) {
+ } else if (ActionEvent.NEXT.equals(event.getAction())) {
nextChannel();
- } else if (event.getType().equals(ActionEvent.PREV)) {
+ } else if (ActionEvent.PREV.equals(event.getAction())) {
prevChannel();
- } else if (event.getType().equals(ActionEvent.CANCEL)) {
+ } else if (ActionEvent.STOP.equals(event.getAction())) {
finish();
}
}
diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
index 19377a477..750647303 100644
--- a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
+++ b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
@@ -1028,13 +1028,13 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
@Subscribe(threadMode = ThreadMode.MAIN)
public void onActionEvent(ActionEvent event) {
- if (event.getType().equals(ActionEvent.PLAY) || event.getType().equals(ActionEvent.PAUSE)) {
+ if (ActionEvent.PLAY.equals(event.getAction()) || ActionEvent.PAUSE.equals(event.getAction())) {
mBinding.control.play.performClick();
- } else if (event.getType().equals(ActionEvent.NEXT)) {
+ } else if (ActionEvent.NEXT.equals(event.getAction())) {
mBinding.control.next.performClick();
- } else if (event.getType().equals(ActionEvent.PREV)) {
+ } else if (ActionEvent.PREV.equals(event.getAction())) {
mBinding.control.prev.performClick();
- } else if (event.getType().equals(ActionEvent.CANCEL)) {
+ } else if (ActionEvent.STOP.equals(event.getAction())) {
finish();
}
}