roy_sanu
asked on
Listener is not working
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.s etListener (new BasicMMAdListener()"
MainActive.txt
"fetchCheckDisplayAdView.s
MainActive.txt
Have you made sure that the code compiles without errors?
ASKER
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
MainActive.txt
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();
}
if(success) {
{
Toast toast3 = Toast.makeText(MainActive.
toast3.show();
}
}
change it to this
if(success) {
String message1 = "success";
Toast toast3 = Toast.makeText(MainActive.
toast3.show();
}
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(MMAdV iew fetchCheckDisplayAdView, boolean success)
{
String message1 = "Testing MMAdCachingCompleted";
Toast toast3 = Toast.makeText(MainActive. this, message1, Toast.LENGTH_SHORT);
toast3.show();
}
public void MMAdCachingCompleted(MMAdV
{
String message1 = "Testing MMAdCachingCompleted";
Toast toast3 = Toast.makeText(MainActive.
toast3.show();
}
Ok , what is the right id you are passing ?
ASKER
91776
But in this line , you are checking for a boolean , not an id :
public void MMAdCachingCompleted(MMAdView fetchCheckDisplayAdView, boolean success)
{
if(success) {
ASKER
Yes i tried this method also, it did not work
public void MMAdReturned(MMAdView fetchCheckDisplayAdView)
{
Log.i(TAG, "(" + adview.getId() + ") View Success");
}
public void MMAdReturned(MMAdView fetchCheckDisplayAdView)
{
Log.i(TAG, "(" + adview.getId() + ") View Success");
}
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'
Change if(success) to if(true) and see . It will shows where the code is 'jumping off'
ASKER
I did that but it still jumps out of this loop from this statements below to out of the loop
"fetchCheckDisplayAdView.s etListener (new BasicMMAdListener(){"
if(true){
String message2 = "pass";
Toast toast2 = Toast.makeText(MainActive. this, message2, Toast.LENGTH_SHORT);
toast2.show();
Log.i(TAG, " Ad (" + fetchCheckDisplayAdView.ge tId() + ") caching completed successfully: " + success);
}
"fetchCheckDisplayAdView.s
if(true){
String message2 = "pass";
Toast toast2 = Toast.makeText(MainActive.
toast2.show();
Log.i(TAG, " Ad (" + fetchCheckDisplayAdView.ge
}
As someone else suggested above , remove the extra { } pair just after if(success) , compile and run
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?
How do you know it jumps out of the loop or how can you tell it was in the loop, then jumped out?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.