Link to home
Start Free TrialLog in
Avatar of roy_sanu
roy_sanuFlag for India

asked on

Listener is not working

Here is my sample code, The Listener is not working, on this line below of the code it jumps out of the loop, it never goes to say whether success or failure. what is issue here

"fetchCheckDisplayAdView.setListener(new BasicMMAdListener()"
MainActive.txt
Avatar of Sharon Seth
Sharon Seth
Flag of India image

Have you made sure that the code compiles without errors?
Avatar of roy_sanu

ASKER

yap, when i pass the right id which i know as sucess  it do not give me any message, but when i pass the wrong id it gives the right result as fails. what mistake i am doing
MainActive.txt
In the first MainActivity.txt it iooks like the the if(success) brackets are not correct, two left brackets in a row, plus you might have two extra brackets surrounding the Toast code, this is your code:
  if(success) {

    {
         
         Toast toast3 = Toast.makeText(MainActive.this, message1, Toast.LENGTH_SHORT);
       toast3.show();      
    }                                                    
                                              
   }

change it to this

  if(success) {
        String message1 = "success";
        Toast toast3 = Toast.makeText(MainActive.this, message1, Toast.LENGTH_SHORT);
       toast3.show();      
    }
If that isn't the solution, perhaps the method MMAdCachingCompleted is not being called when you pass the right ID. You can further troubleshoot the code by placing the Toast message inside the MMAdCachingCompleted at the top of the method outside of any If Else statement to see if it's being called when you know you pass the right ID. The result of this test will tell you something.

public void MMAdCachingCompleted(MMAdView fetchCheckDisplayAdView, boolean success)
{
      String message1 = "Testing MMAdCachingCompleted";
      Toast toast3 = Toast.makeText(MainActive.this, message1, Toast.LENGTH_SHORT);
       toast3.show();  

}
Ok , what is the right id you are passing ?
91776
But in this line , you are checking for a boolean , not an id :

public void MMAdCachingCompleted(MMAdView fetchCheckDisplayAdView, boolean success)
			{
  				if(success) {

Open in new window

Yes i tried this method also, it did not work

public void MMAdReturned(MMAdView fetchCheckDisplayAdView)
      {
            Log.i(TAG, "(" + adview.getId() + ") View Success");
      }
The id 91776 simply is not turning success to true .
Change if(success) to if(true) and see . It will shows where the code is 'jumping off'
I did that but it still jumps out of this loop from this statements below to out of the loop
"fetchCheckDisplayAdView.setListener(new BasicMMAdListener(){"

if(true){
                           String message2 = "pass";
                      Toast toast2 = Toast.makeText(MainActive.this, message2, Toast.LENGTH_SHORT);
                      toast2.show();
                      
                     Log.i(TAG, " Ad (" + fetchCheckDisplayAdView.getId() + ") caching completed successfully: " + success);
               }
As someone else suggested above , remove the extra { } pair just after if(success) , compile and run
Hi roy_sanu,

How do you know it jumps out of the loop or how can you tell it was in the loop, then jumped out?
ASKER CERTIFIED SOLUTION
Avatar of Santhana
Santhana
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial