I have public class MyFirebaseInstanceIdService
to handle firebase notifications when the app is in the background.
public class MyFirebaseInstanceIdService extends FirebaseInstanceIdService {
@Override
public void onTokenRefresh() {
MainActivity.sendRegToken();
}
}
MainActivity
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
WebView webView = (WebView) findViewById(R.id.webView);
public void sendRegToken() {
String recent_token = FirebaseInstanceId.getInstance().getToken();
webView.loadUrl("javascript:sendRegToken('"+recent_token+"');");
}
}
I need access to webView
so I can call loadUrl
. sendRegToken()
is a non-static method, and I'm trying to access it from a static context. I can't make sendRegToken()
static because it contains the non-static webView
. How do I get around this problem?