Solved

Listener is not working

Posted on 2013-01-22
13
302 Views
Last Modified: 2013-01-30
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
0
Comment
Question by:roy_sanu
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 12

Expert Comment

by:Sharon Seth
ID: 38808694
Have you made sure that the code compiles without errors?
0
 

Author Comment

by:roy_sanu
ID: 38808912
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
0
 
LVL 12

Expert Comment

by:PCableGuy
ID: 38812704
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();      
    }
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 12

Expert Comment

by:PCableGuy
ID: 38812756
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();  

}
0
 
LVL 12

Expert Comment

by:Sharon Seth
ID: 38813141
Ok , what is the right id you are passing ?
0
 

Author Comment

by:roy_sanu
ID: 38813177
91776
0
 
LVL 12

Expert Comment

by:Sharon Seth
ID: 38813315
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

0
 

Author Comment

by:roy_sanu
ID: 38813340
Yes i tried this method also, it did not work

public void MMAdReturned(MMAdView fetchCheckDisplayAdView)
      {
            Log.i(TAG, "(" + adview.getId() + ") View Success");
      }
0
 
LVL 12

Expert Comment

by:Sharon Seth
ID: 38813568
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'
0
 

Author Comment

by:roy_sanu
ID: 38813817
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);
               }
0
 
LVL 12

Expert Comment

by:Sharon Seth
ID: 38813853
As someone else suggested above , remove the extra { } pair just after if(success) , compile and run
0
 
LVL 12

Expert Comment

by:PCableGuy
ID: 38816780
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?
0
 
LVL 8

Accepted Solution

by:
Santhana earned 500 total points
ID: 38817423
Hi  roy_sanu,
  fetchCheckDisplayAdView.fetch();
  fetchCheckDisplayAdView.setListener(new BasicMMAdListener() {)});

Open in new window


From the above 2 lines , u are calling fectch() function before registering register.
And the next line u are registering the listener.
I guess the listener will be called based on the state of the fectch operation.

Here, the fetch operation may be finished before registering  the listener. (Currentlyyou haven't attached the code for the operations u r doing it in the fetch operation).
In this cause it may not call this callback function "MMAdCachingCompleted()"

So analyze u r code in this perspective.

Regards
Santhana
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
messenger app crashes 7 55
Portable WiFi hotspot through ATT phone 4 42
wondershare 17 61
Built in memory vs SD card. 3 75
You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
Here, we have shared an easy step by step tutorial on how to download instagram images and videos on PC, Android Mobile and iOS mobile.
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question