How to return a string in an extension?

hi so im a noob im trying to create an extensions
i created the extension successfully here how my function looks like

@SimpleFunction
public void UsbConfiguration_getName (){
usbConfiguration.getName();
}

this extension returns a String i don't know how to convert it to send the string to lable

could anyone help me ?

The signature of your function doesn't match your explanation. The function is marked as returning void but you say it is supposed to return String. So why not make it return String?

as i said im not an expert im taking a look at extensions and tring to learn i doing that cause i need this feature for my app

https://developer.android.com/reference/android/hardware/usb/UsbConfiguration#getName()

i tried this
@SimpleFunction
public void UsbConfiguration_getName (String Name){
usbConfiguration.getName(Name);
}
but the extension doesn't compile

What error do you get when it doesn't compile?

error: method getName in class UsbConfiguration cannot be applied to given types;
[javac] usbConfiguration.getName(Name);

btw i've just tried this

@SimpleFunction
public boolean UsbConfiguration_isSelfPowered (){
return usbConfiguration.isSelfPowered();
}

it compiled but i didn't test it yet

You must have to change void to string because a void method can't return anything.

Be sure it will work.

1 Like

@vknow360 @ewpatton
thanks guys i fixed it i didn't follow the docs as it is i made mistakes
i used public void for all the functions that wa my mistake