kstasadduq
New Member
I need to use the following inline java code in my B4A application:
But getting the following error:
B4A Version: 11.50
Parsing code. (0.88s)
Java Version: 8
Building folders structure. (0.32s)
Compiling code. (4.67s)
Compiling layouts code. (0.09s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Compiling resources (1.14s)
Linking resources (3.56s)
Compiling debugger engine code. (0.23s)
Compiling generated Java code. Error
javac 1.8.0_333
src\com\friendzapp\moneymanager\secugen.java:145: error: cannot find symbol
public void onReceive(Context context, Intent intent) {
^
symbol: class Context
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Java:
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//This broadcast receiver is necessary to get user permissions to access the attached USB device
private static final String ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION";
private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
//Log.d(TAG,"Enter mUsbReceiver.onReceive()");
if (ACTION_USB_PERMISSION.equals(action)) {
synchronized (this) {
UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
if(device != null){
//DEBUG Log.d(TAG, "Vendor ID : " + device.getVendorId() + "\n");
//DEBUG Log.d(TAG, "Product ID: " + device.getProductId() + "\n");
debugMessage("USB BroadcastReceiver VID : " + device.getVendorId() + "\n");
debugMessage("USB BroadcastReceiver PID: " + device.getProductId() + "\n");
}
else
Log.e(TAG, "mUsbReceiver.onReceive() Device is null");
}
else
Log.e(TAG, "mUsbReceiver.onReceive() permission denied for device " + device);
}
}
}
};
But getting the following error:
B4A Version: 11.50
Parsing code. (0.88s)
Java Version: 8
Building folders structure. (0.32s)
Compiling code. (4.67s)
Compiling layouts code. (0.09s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Compiling resources (1.14s)
Linking resources (3.56s)
Compiling debugger engine code. (0.23s)
Compiling generated Java code. Error
javac 1.8.0_333
src\com\friendzapp\moneymanager\secugen.java:145: error: cannot find symbol
public void onReceive(Context context, Intent intent) {
^
symbol: class Context
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error