Set Loudspeaker mode "Active" on call starts, Please help me

I am new to Kodular extension development,
I am using “https://editor.appybuilder.com/” to create extensions
I want to make Loudspeaker ON when call starts, and unable to write the code, My code is in below,

import android.content.Context;
import android.util.Log;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;
import android.telephony.TelephonyManager;
import android.media.AudioManager;

@DesignerComponent(version = 1,  description = "",
        category = ComponentCategory.EXTENSION,
        nonVisible = true,   iconName = "http://appyBuilder.com/extensions/icons/extension.png")
@SimpleObject(external = true)
public class SpeakerOn extends AndroidNonvisibleComponent {
    private ComponentContainer container;
    /**
     * @param container container, component will be placed in
     */
    public SpeakerOn(ComponentContainer container) {
        super(container.$form());
        this.container = container;
    }
  
    @SimpleFunction(description = "Set LoudSpeaker ON")
    public void SetLoudSpeakerOn() {
AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); audioManager.setMode(AudioManager.MODE_IN_CALL);
audioManager.setSpeakerphoneOn(true);
                                   }
      }

please someone help me…

pls also show the error log

Buildfile: /projects/goldv2/appinventor-sources/appinventor/build.xml

extensions:

clean:

init:

common_CommonUtils:

init:

CommonUtils:

common_CommonVersion:

init:

CommonVersion:
[exec] Result: 128
[exec] Result: 128

CopyToRunLibDir:

components_AndroidRuntime:

init:

CommonConstants:
[javac] Compiling 6 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/CommonConstants
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning

HtmlEntities:
[javac] Compiling 1 source file to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/HtmlEntities
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning

common_CommonVersion:

init:

CommonVersion:
[exec] Result: 128
[exec] Result: 128

AndroidRuntime:
[javac] Compiling 332 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/rkrajesh_arm/SpeakerOn/SpeakerOn.java:39: error: cannot find symbol
[javac] AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
[javac] ^
[javac] symbol: method getSystemService(String)
[javac] location: class SpeakerOn
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 error
[javac] 1 warning

BUILD FAILED
/projects/goldv2/appinventor-sources/appinventor/build.xml:35: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:372: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/components/build.xml:141: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:118: Compile failed; see the compiler error output for details.

Total time: 7 seconds
r

common_CommonVersion:

init:

CommonVersion:
[exec] Result: 128
[exec] Result: 128

AndroidRuntime:
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] Compiling 332 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/rkrajesh_arm/SpeakerOn/SpeakerOn.java:39: error: cannot find symbol
[javac] AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
[javac] ^
[javac] symbol: method getSystemService(String)
[javac] location: class SpeakerOn
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 error
[javac] 1 warning

BUILD FAILED
/projects/goldv2/appinventor-sources/appinventor/build.xml:35: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:372: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/components/build.xml:141: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:118: Compile failed; see the compiler error output for details.

Total time: 7 seconds

You should do context.getSystemService(Context.AUDIO_SERVICE) after initializing the variable.

Here’s how to do it: Context error while develope extension - #6 by SquishyOctopus

AndroidRuntime:
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] Compiling 332 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/rkrajesh_arm/SpeakerOn/SpeakerOn.java:35: error: cannot find symbol
[javac] this.context = container.$context();
[javac] ^
[javac] symbol: variable context
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/rkrajesh_arm/SpeakerOn/SpeakerOn.java:40: error: cannot find symbol
[javac] AudioManager udioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
[javac] ^
[javac] symbol: variable context
[javac] location: class SpeakerOn
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 errors
[javac] 1 warning

Not working…
Becoming hopeless

import android.content.Context;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;
import android.telephony.TelephonyManager;
import android.media.AudioManager;

public class SpeakerOn extends AndroidNonvisibleComponent {
    private ComponentContainer container;
    private Context context;

    public SpeakerOn(ComponentContainer container) {
      super(container.$form());
      this.container = container;
      this.context = container.$context();
    }

    @SimpleFunction
    public void SetLoudSpeaker(boolean toggled) {
        AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        audioManager.setMode(AudioManager.MODE_IN_CALL);
        audioManager.setSpeakerphoneOn(toggled);
    }
}

Buildfile: /projects/goldv2/appinventor-sources/appinventor/build.xml

extensions:

clean:

init:

common_CommonUtils:

init:

CommonUtils:

common_CommonVersion:

init:

CommonVersion:
[exec] Result: 128
[exec] Result: 128

CopyToRunLibDir:

components_AndroidRuntime:

init:
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/build/components
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build
[mkdir] Created dir: /projects/goldv2/appinventor-sour
CopyToRunLibDir:

components_AndroidRuntime:

init:

CommonConstants:
[javac] Compiling 6 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/CommonConstants
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning

HtmlEntities:
[javac] Compiling 1 source file to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/HtmlEntities
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning

common_CommonVersion:

init:

CommonVersion:
[exec] Result: 128
[exec] Result: 128

AndroidRuntime:
[javac] Compiling 332 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 warning

components_Barcode:

Barcode:

components_ComponentList:

init:

CommonConstants:

ComponentProcessingLib:

HtmlEntities:

common_CommonUtils:

init:

CommonUtils:

AnnotationProcessors:
[jar] Building jar: /projects/goldv2/appinventor-sources/appinventor/components/build/AnnotationProcessors.jar

common_CommonVersion:

init:

CommonVersion:
[exec] Result: 128
[exec] Result: 128

AndroidRuntime:
[javac] Compiling 15 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning

Barcode:

ComponentList:
[javac] Compiling 307 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/ComponentList
[javac] warning: No SupportedSourceVersion annotation found on com.google.appinventor.components.scripts.ComponentListGenerator, returning RELEASE_6.
[javac] warning: Supported source version ‘RELEASE_6’ from annotation processor ‘com.google.appinventor.components.scripts.ComponentListGenerator’ less than -source ‘1.8’
[javac] Note: Wrote file file:/projects/goldv2/appinventor-sources/appinventor/components/build/classes/ComponentList/simple_components.txt
[javac] Note: Wrote file file:/projects/goldv2/appinventor-sources/appinventor/components/build/classes/ComponentList/simple_components_build_info.json
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 warnings

BuildServer:
[jar] error while reading original manifest in file: /projects/goldv2/appinventor-sources/appinventor/buildserver/build/run/lib/BuildServer.jar due to error in opening zip file
[jar] Building jar: /projects/goldv2/appinventor-sources/appinventor/buildserver/build/run/lib/BuildServer.jar

init:

CommonConstants:

HtmlEntities:

common_CommonVersion:

init:

CommonVersion:
[exec] Result: 128
[exec] Result: 128

AndroidRuntime:
[javac] Compiling 15 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning

ComponentProcessingLib:

common_CommonUtils:

init:

CommonUtils:

AnnotationProcessors:

JsonComponentDescription:
[javac] Compiling 307 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/JsonComponentDescription
[javac] warning: No SupportedSourceVersion annotation found on com.google.appinventor.components.scripts.ComponentDescriptorGenerator, returning RELEASE_6.
[javac] warning: Supported source version ‘RELEASE_6’ from annotation processor ‘com.google.appinventor.components.scripts.ComponentDescriptorGenerator’ less than -source ‘1.8’
[javac] Note: Wrote file file:/projects/goldv2/appinventor-sources/appinventor/components/build/classes/JsonComponentDescription/simple_components.json
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 warnings

Barcode:

ComponentList:
[javac] Compiling 15 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/ComponentList
[javac] warning: No SupportedSourceVersion annotation found on com.google.appinventor.components.scripts.ComponentListGenerator, returning RELEASE_6.
[javac] warning: Supported source version ‘RELEASE_6’ from annotation processor ‘com.google.appinventor.components.scripts.ComponentListGenerator’ less than -source ‘1.8’
[javac] 2 warnings

ExternalComponentGenerator:
[java]
[java] Extensions : Generating extensions
[java]
[java] Extensions : Generating files [com.appybuilder.rkrajesh_arm.LoudSpeakedOnCall]
[java] java.io.IOException: Unable to create temporary path for extension build
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:195)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:772)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:222)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:136)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:109)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
[java] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:498)
[java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[java] at org.apache.tools.ant.Task.perform(Task.java:348)
[java] at org.apache.tools.ant.Target.execute(Target.java:435)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:456)
[java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
[java] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
[java] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
[java] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:498)
[java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[java] at org.apache.tools.ant.Task.perform(Task.java:348)
[java] at org.apache.tools.ant.Target.execute(Target.java:435)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:456)
[java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
[java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:853)
[java] at org.apache.tools.ant.Main.startAnt(Main.java:235)
[java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
[java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
[java] Caused by: java.io.IOException: Unable to create temporary path for extension build
[java] at com.google.appinventor.components.scripts.ExternalComponentGenerator.generateExternalComponentBuildFiles(ExternalComponentGenerator.java:163)
[java] at com.google.appinventor.components.scripts.ExternalComponentGenerator.generateAllExtensions(ExternalComponentGenerator.java:110)
[java] at com.google.appinventor.components.scripts.ExternalComponentGenerator.main(ExternalComponentGenerator.java:70)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:498)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:218)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:153)
[java] … 32 more
[java] Java Result: -1

unjarAllExtensionLibraries:

unjarExtensionLibraries:

jarAllExtensions:

jarExtension:
[echo] Generated build file AndroidRuntime.jar [com.appybuilder.rkrajesh_arm.LoudSpeakedOnCall]

dexAllExtensions:

dexExtension:
[echo] Dexing extension: com.appybuilder.rkrajesh_arm.LoudSpeakedOnCall

extensions:

packExtension:
[zip] Building zip: /var/www/html/logs/com.appybuilder.rkrajesh_arm.LoudSpeakedOnCall.aix

BUILD SUCCESSFUL
Total time: 29 seconds
ning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning

ComponentProcessingLib:

common_CommonUtils:

init:

CommonUtils:

AnnotationProcessors:

JsonComponentDescription:
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/classes/JsonComponentDescription
[javac] Compiling 307 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/JsonComponentDescription
[javac] warning: No SupportedSourceVersion annotation found on com.google.appinventor.components.scripts.ComponentDescriptorGenerator, returning RELEASE_6.
[javac] warning: Supported source version ‘RELEASE_6’ from annotation processor ‘com.google.appinventor.components.scripts.ComponentDescriptorGenerator’ less than -source ‘1.8’
[javac] Note: Wrote file file:/projects/goldv2/appinventor-sources/appinventor/components/build/classes/JsonComponentDescription/simple_components.json
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 warnings
[javac] Creating empty /projects/goldv2/appinventor-sources/appinventor/components/build/classes/JsonComponentDescription/com/google/appinventor/components/runtime/util/package-info.class
[javac] Creating empty /projects/goldv2/appinventor-sources/appinventor/components/build/classes/JsonComponentDescription/com/google/appinventor/components/runtime/collect/package-info.class
[javac] Creating empty /projects/goldv2/appinventor-sources/appinventor/components/build/classes/JsonComponentDescription/com/google/appinventor/components/runtime/package-info.class
[javac] Creating empty /projects/goldv2/appinventor-sources/appinventor/components/build/classes/JsonComponentDescription/com/google/appinventor/components/runtime/errors/package-info.class
[copy] Copying 1 file to /projects/goldv2/appinventor-sources/appinventor/build/components

Barcode:

ComponentList:
[javac] Compiling 15 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/ComponentList
[javac] warning: No SupportedSourceVersion annotation found on com.google.appinventor.components.scripts.ComponentListGenerator, returning RELEASE_6.
[javac] warning: Supported source version ‘RELEASE_6’ from annotation processor ‘com.google.appinventor.components.scripts.ComponentListGenerator’ less than -source ‘1.8’
[javac] 2 warnings

ExternalComponentGenerator:
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/classes/ExternalComponentGenerator
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/externalComponents
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/externalComponents-class
[javac] Compiling 1 source file to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/ExternalComponentGenerator
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning
[java]
[java] Extensions : Generating extensions
[java]
[java] Extensions : Generating files [com.appybuilder.rkrajesh_arm.LoudSpeakedOnCall]
[java] Extensions : Copying file com/appybuilder/rkrajesh_arm/LoudSpeakedOnCall/LoudSpeakedOnCall.class
[java] Extensions : Successfully created com.appybuilder.rkrajesh_arm.LoudSpeakedOnCall build info file
[java] Extensions : Successfully created com.appybuilder.rkrajesh_arm.LoudSpeakedOnCall extension properties file

unjarAllExtensionLibraries:

unjarExtensionLibraries:

jarAllExtensions:

jarExtension:
[jar] Building jar: /projects/goldv2/appinventor-sources/appinventor/components/build/externalComponents-class/com.appybuilder.rkrajesh_arm.LoudSpeakedOnCall.jar
[copy] Copying 1 file to /projects/goldv2/appinventor-sources/appinventor/components/build/externalComponents/com.appybuilder.rkrajesh_arm.LoudSpeakedOnCall/files
[echo] Generated build file AndroidRuntime.jar [com.appybuilder.rkrajesh_arm.LoudSpeakedOnCall]

dexAllExtensions:

dexExtension:
[echo] Dexing extension: com.appybuilder.rkrajesh_arm.LoudSpeakedOnCall

extensions:

packExtension:
[zip] Building zip: /var/www/html/logs/com.appybuilder.rkrajesh_arm.LoudSpeakedOnCall.aix

BUILD SUCCESSFUL
Total time: 28 seconds

But no AIX file created, what is happening to me

I don’t know what to tell you, but I and no one else is going to solve all of your problems.

Definitely, I appreciate your help. and thanks a lot, stay blessed and happy