Solved

Listener is not working

Posted on 2013-01-22
13
307 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

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Working settings for French ISP Orange "Prêt à Surfer" SIM cards for data connections only. Can't be found anywhere else !
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

691 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