Why this java code not working?

really i don't have any idea about java.
please re-edit this

This is why it’s so important for you to do it yourself. It’s the only way you will learn.

If you don't know java you should consider learning Java first then build some basic extensions.

1 Like

but it will give me an idea.
please help me

You’ve been given help in post #2. You are refusing to do anything yourself. At this point you are now spamming by asking for help over and over again.

1 Like

I am also new to java and extension development.

Some steps which I followed.

  • Daily watch tutorials and guides on youtube, approx 1 hour.
  • Trying to build extension!
  • Results - If fail
  • Do some research in google/stackoverflow
  • If it doesn't help me
  • Get help from others (not to ask full)
  • Else - Next code

You know today I took more than 2 hours solving problems in my BinaryTools extension, finally passed! :relaxed:

what to use in that case

I don't know. As the others have stated, you may want to start simple first and learn how to build a component and an extension for App Inventor before getting too complicated. As I mentioned in my earlier statements, you likely aren't going to be able to make this work due to issue #2.

3 Likes

thanks, i have learn many things.
but i am still getting error.

please check my Modified code

package com.ads.inter;  

import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.util.MediaUtil;
import com.google.appinventor.components.runtime.*;
  
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;
import android.support.v7.app.AppCompatActivity;  
import android.os.Bundle;
  
import com.google.android.gms.ads.AdListener;  
import com.google.android.gms.ads.AdRequest;  
import com.google.android.gms.ads.InterstitialAd;  
  
@DesignerComponent(version = 1, // Update version here, You must do for each new release to upgrade your extension
               description = "interads",
               category = ComponentCategory.EXTENSION,
               nonVisible = true,
               iconName = "images/extension.png") // Change your extension's icon from here; can be a direct url
@SimpleObject(external = true)
public class interads extends AndroidNonvisibleComponent {  
InterstitialAd mInterstitialAd;  
  
@Override  
protected void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.activity_interstitial_ads);  
    mInterstitialAd = new InterstitialAd(this);  
  
    // set the ad unit ID  
@SimpleFunction
public String SetAdUnit(String UnitId) {
    mInterstitialAd.setAdUnitId(UnitId);  
 }
  
    AdRequest adRequest = new AdRequest.Builder().build();  
  
    // Load ads into Interstitial Ads  
 @SimpleFunction
public String LoadAd{
    mInterstitialAd.loadAd(adRequest);  
  
    @SimpleEvent
	public void onAdLoaded{  
           EventDispatcher.dispatchEvent(this, "onAdLoaded");  
        }    
}  

  @Override
private void showInterstitial{  
    if (mInterstitialAd.isLoaded()) {  
        mInterstitialAd.show();  
    }  
}  
  
  
}

You have referred my code right? :grinning: :grinning:

1 Like

???

You didn't return anything. If you don't want to return anything, add void keyword.
Secondly, many of your method don't have () parameters

Thirdly, to make a proper event,

@SimpleEvent(description = "Description here")
public void onAdLoaded(){
   EventDispatcher.dispatchEvent(this, "onAdLoaded");
}

@SimpleFunction(description = "") 
public void LoadAd() {
  //Your code
  onAdLoaded();
}
1 Like

He had asked me for source of old binary extension...

But this is an ad extension.

1 Like

Just he wants to know how extension is made...

it's still not working please help me.
can you edit my file please.
here is my code

package com.ads.inter;  

import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.util.MediaUtil;
import com.google.appinventor.components.runtime.*;
  
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;
import android.support.v7.app.AppCompatActivity;  
import android.os.Bundle;
  
import com.google.android.gms.ads.AdListener;  
import com.google.android.gms.ads.AdRequest;  
import com.google.android.gms.ads.InterstitialAd;  
  
@DesignerComponent(version = 1, // Update version here, You must do for each new release to upgrade your extension
                   description = "interads",
                   category = ComponentCategory.EXTENSION,
                   nonVisible = true,
                   iconName = "images/extension.png") // Change your extension's icon from here; can be a direct url
@SimpleObject(external = true)
public class interads extends AndroidNonvisibleComponent {  
    InterstitialAd mInterstitialAd;  
  
    @Override  
    protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_interstitial_ads);  
        mInterstitialAd = new InterstitialAd(this);  
  
        // set the ad unit ID  
    @SimpleFunction
    public String SetAdUnit(String UnitId) {
        mInterstitialAd.setAdUnitId(UnitId);  
     }
  
        AdRequest adRequest = new AdRequest.Builder().build();  
  
        // Load ads into Interstitial Ads  
 @SimpleFunction(description = "load ad")
    public void LoadAd{
        mInterstitialAd.loadAd(adRequest);  
  }
        
@SimpleEvent(description = "On ad loaded")
public void onAdLoaded(){
   EventDispatcher.dispatchEvent(this, "onAdLoaded");
}

  @Override
    private void showInterstitial{  
        if (mInterstitialAd.isLoaded()) {  
            mInterstitialAd.show();  
        }  
    }  
  
  
}

First try to make small extension, they try big. :grinning:

1 Like

You didn't follow what I have said

2 Likes

i am doing but i want to make some big. :smiley: :smile:
so, please help me

can you show me where i have to add this parameters

1 Like

:point_down: The real issue is this

issue
6 Likes