Why this java code not working?

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

Yeah, if you don't know java, and want to make extensions try making something simple as @Kumaraswamy recommended, making something big will come later on

3 Likes

i accepting that i don't have any knowledge about JAVA.
But i know Only app inventor can help me.

now i have added some parameters.
but it still not working.
my modifies 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();  
        }  
    }  
  
  
}

So you have to hire someone to do it for youo.

2 Likes

can you check my code again pleaseee

You should learn java first. suppose if you made extension without knowing or learning java with the help of ai2 community but what if the ad network update their sdk then you will again take help? thats why you need to learn java first

4 Likes

yes, you are absolutely correct .
As i know App inventor code and java have some different code.
So, i am thinking to create extension. Which is easy .
Or it will also give me an idea to JAVA.

Please Help me
please check my code

here you are thinking wrong extensions are based on java. java is not based on extensions

2 Likes

okay,i will never ask for editing my java file.
but i am stuck at this point.
so, please check my code

:point_down: :point_down:

Hope you understood...

5 Likes

Thanks I am Understanding what are you saying :100:.
One more question - can you check my all Import in my extension.

please reply this question

I have no idea about making ad extensions.

1 Like

ohh then @WatermelonIce
can you help me