我正在开发使用 OneSignal API 接收推送消息的应用程序。在处理打开消息的代码下方:
接收者
public class OneSignalBroadcastReceiver extends BroadcastReceiver implements OneSignal.NotificationOpenedHandler {
private static RecadosDataSource rec;
private static Context mcontext;
private static Boolean opened = false;
private static String Titulo = "";
private static String Mensagem = "";
@Override
public void notificationOpened(String message, JSONObject additionalData, boolean isActive) {
try {
this.mcontext = MainActivity.getInstance().getApplication().getApplicationContext();
rec = new RecadosDataSource(this.mcontext);
databaseManager(true,this.mcontext);
rec.updateRecados(additionalData.getString("title"), message);
databaseManager(false, this.mcontext);
} catch (Throwable t) {
t.printStackTrace();
}
}
}
问题是如何在这个类中获取上下文?以目前的方式,我无法获得上下文。