Solved

Listener is not working

Posted on 2013-01-22
13
299 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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:
santhanasamy 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Android SDK is used for creating an android software application. It includes document and tools which are necessary to develop applications with java. In fact Android SDK is harder than other software infrastructure, because there is a virtual devi…
Working settings for French ISP Orange "Prêt à Surfer" SIM cards for data connections only. Can't be found anywhere else !
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now