I strongly recommend you please start with basic and learn some basic core concept of JAVA because we have lots of hope from you.
every extension developer made something new which helps community so best of luck for extension development.
please fell free to ask question
1 Like
Oh sorry that was my mistake, I forgot to change the integer
1 Like
Thank you for fixing the code but I suggest you to don't need to add this line :
int linkSpeed = 0;
because it's not important, it's like you initialized the integer twice
1 Like
no my dear friend in case of wifiInfo = null linkSpeed is not defined.
2 Likes
oh yeah i think you are right but it still error
1 Like
its still error because you initialize it on the code
1 Like
you should do like this :
package com.salman.test;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiInfo;
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.ComponentCategory;
@DesignerComponent(version = 1, description = "This Extension was created with the AppyBuilder Code Editor.<br>" +
"Create your own here:<br><a href='https://editor.appybuilder.com' target='_blank'>https://editor.appybuilder.com</a><br>",
category = ComponentCategory.EXTENSION,
nonVisible = true, iconName = "http://appyBuilder.com/extensions/icons/extension.png")
@SimpleObject(external = true)
public class Testing extends AndroidNonvisibleComponent {
private ComponentContainer container;
private int linkSpeed = 0;
public Testing(ComponentContainer container) {
super(container.$form());
this.container = container;
}
@SimpleFunction(description = "DESCRIPTION OF METHOD.")
public int GetWifiSpeed () {
WifiManager wifiManager = (WifiManager) container.$context().getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo != null) {
int linkSpeed = wifiInfo.getLinkSpeed();
}
return linkSpeed;
}
}
So the problem is you can't initialize the int in the code, you have to initialize the code outside the function. Works 100%
2 Likes
no it not required
according to me why we need to create one instance variable of object because we need only value at runtime after method execution we are not interested in linkSpeed but if we create instance variable then it will stored into heap memory.
1 Like
preetvadaliya:
no it not required
then why don't you try compiling the code you edited? I've tried compiling the code you edited and it doesn't work.
and the code that I have edited works 100%
1 Like
Are you sure Salman? That would just return the value 0.
1 Like
i think im sure sir
please guide me if I am wrong
1 Like
Meulencv:
Internet_speed
please follow the naming conventions
If you are developing an extension, then please follow the naming conventions, which is UpperCamelCase for the package name as well as for property, method and event names (i.e. the first letter should be a capital letter) and lowerCamelCase for parameter names, no underscores .
Example
[naming]
What does UpperCamelCase mean?
UpperCamelCase (part of CamelCase ) is a naming convention in which a name is formed of multiple words that are joined together as a single word with the first lā¦
Taifun
Trying to push the limits! Snippets , Tutorials and Extensions from Pura Vida Apps by Taifun.
1 Like