Solved

Listener is not working

Posted on 2013-01-22
13
305 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Update Samsung Galaxy S3 to Android 5 or 6 5 70
QQ problem 22 89
moto 4g file transfer 12 103
Android 7.0 gets error constantly "Delivery has stopped. Close app" 14 66
Introduction Everyone is using a smartphone these days. Contacts, messages, applications, documents, bookmarks, pictures, videos and other stuff which you created and are present only on your device come under the umbrella called “Personal Data”.…
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
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.
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…

734 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