Android Java access WebView in MainActivity from other class -


i have public class myfirebaseinstanceidservice handle firebase notifications when app in 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 webview can call loadurl. sendregtoken() non-static method, , i'm trying access static context. can't make sendregtoken() static because contains non-static webview. how around problem?

use class localbroadcastmanager example can found here : localbroadcastmanager example 1.register broadcast on mainactivity. 2.send broadcast ontokenrefesh() parameters need inside intent send.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -