I am new on Java android code, please help me how to access String variable from one method to another method, this is from my code, I want to use variable deviceToken, to pass the value to another method that using javascriptinterface
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onNewToken(String token) {
Log.d("TokenFcm",token);
String deviceToken = token ;
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
}
public class MyFirebaseMessagingService extends FirebaseMessagingService {
String deviceToken = "";
@Override
public void onNewToken(String token) {
Log.d("TokenFcm",token);
deviceToken = token ;
}
public void anotherMethod(){
System.out.println(deviceToken);
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
} ```
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.