在后台 returns 字符串中线程 运行 到任何当前 activity 的处理程序

Thread running in background returns strings to handler of whatever current activity

我正在尝试接收当前 activity 的消息,而不仅仅是 MainActivity 后台服务: MainActivity.bluetoothIn.obtainMessage(handlerState, bytes, -1, readMessage).sendToTarget(); 主要活动: 这是从后台服务接收消息的处理程序。 现在我正在尝试做的是如何使我想要从该后台服务中查看消息的所有活动成为可能。任何帮助将不胜感激。 'currentActivity'.bluetoothIn.obtainMessage(handlerState, bytes, -1, readMessage).sendToTarget();

请制作这个class,

public class MyApp extends Application {
MyService myService;

@Override
public void onCreate() {
    super.onCreate();
    myService = new MyService(this);
    mServiceIntent = new Intent(getCtx(), myService.getClass());
    }
}
public Context getCtx() {
    return ctx = this;
}

并在所有活动中接收消息,如明智的 MainActivity