Android Question BA.Log don't work in inline java code

asales

Well-Known Member
Licensed User
I'm trying to use this code to see the log in the java code:
B4X:
#if Java
public static class MyAdListener extends com.google.android.gms.ads.AdListener {
   String eventName = "nativead";
  
   BA.Log(eventName);
  
   @Override
   public void onAdClosed() {
       processBA.raiseEventFromDifferentThread(null, null, 0, eventName + "_adclosed", false, null);
   }
https://www.b4x.com/android/forum/threads/any-news-about-native-ads-advanced.88100/#post-562893

But I get this error in compile:
B4X:
javac 1.8.0_92
src\br\com\b4a\testes\main.java:1788: error: <identifier> expected
   BA.Log(eventName);
         ^
1 error
How I can see log in inline java code?
 

Emme Developer

Well-Known Member
Licensed User
I don't know Java, but i think the problem is that you are writing B4.Log in a definition of a static class. Try to put it in a method and call the method using JavaObject

B4X:
#if Java
public static class MyAdListener extends com.google.android.gms.ads.AdListener {
   String eventName = "nativead";
 
  public void CallLog(){
     BA.Log(eventName);
    } 
 
   @Override
   public void onAdClosed() {
       processBA.raiseEventFromDifferentThread(null, null, 0, eventName + "_adclosed", false, null);
   }
 
Upvote 0

wes58

Active Member
Licensed User
I'm trying to use this code to see the log in the java code:
B4X:
#if Java
public static class MyAdListener extends com.google.android.gms.ads.AdListener {
   String eventName = "nativead";
 
   BA.Log(eventName);
 
   @Override
   public void onAdClosed() {
       processBA.raiseEventFromDifferentThread(null, null, 0, eventName + "_adclosed", false, null);
   }
https://www.b4x.com/android/forum/threads/any-news-about-native-ads-advanced.88100/#post-562893

But I get this error in compile:
B4X:
javac 1.8.0_92
src\br\com\b4a\testes\main.java:1788: error: <identifier> expected
   BA.Log(eventName);
         ^
1 error
How I can see log in inline java code?

You could do it like this:
B4X:
#if Java
import android.util.Log;

public static class MyAdListener extends com.google.android.gms.ads.AdListener {
   String eventName = "nativead";
 
   Log.e("B4A", eventName);
 
   @Override
   public void onAdClosed() {
       processBA.raiseEventFromDifferentThread(null, null, 0, eventName + "_adclosed", false, null);
   }
 
Upvote 0
Top