?
Solved

Listener is not working

Posted on 2013-01-22
13
Medium Priority
?
309 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

 
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 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
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.

764 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