简体   繁体   中英

How to Get current URL in another class from WebView which is in MainActivity

When I get a push notification, I want to check current url in WEBVIEW (which is in MainActivity.java) from another class FcmMessagingService.java .

If currentUrl == mentioned URL, I want to perform specific task.

Can you tell how to get currenturl from MainActivity?

   public class FcmMessagingService extends FirebaseMessagingService {

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);

    String title = remoteMessage.getNotification().getTitle();

if (currenturl == "www.example.com")) {
   // task    
}else{

}       

To get currenturl do this

currenturl= mWebView.getUrl();

Replace currenturl = "www.example.com"

with currenturl.equals("www.example.com")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM