Android Question Problem with Java inline code.

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
I'm trying to compile my app with these two functions:

B4X:
#If JAVA
public static boolean isMockLocationSettingsON(Context context) {
        // returns true if mock location enabled, false if not enabled.
if (Settings.Secure.getString(context.getContentResolver(),
         Settings.Secure.ALLOW_MOCK_LOCATION).equals("0")) {
         return false;
  
} else {
  return true;
  
}  
}
#End If

#If JAVA
public static ArrayList getListOfMockPermissionApps(Context context) {
  ArrayList mockPermissionApps = new ArrayList();
  PackageManager pm = context.getPackageManager();
  List packages = pm
    .getInstalledApplications(PackageManager.GET_META_DATA);

  for (ApplicationInfo applicationInfo : packages) {
   try {
    PackageInfo packageInfo = pm.getPackageInfo(
      applicationInfo.packageName,
      PackageManager.GET_PERMISSIONS);

    // Get Permissions
    String[] requestedPermissions = packageInfo.requestedPermissions;

    if (requestedPermissions != null) {
     for (int i = 0; i < requestedPermissions.length; i++) {
      if (requestedPermissions[i]
        .equals("android.permission.ACCESS_MOCK_LOCATION")
        && !applicationInfo.packageName.equals(context
          .getPackageName())) {
       mockPermissionApps.add(applicationInfo.packageName);
      }
     }
    }
   } catch (NameNotFoundException e) {
   }
  }
  return mockPermissionApps;
}
#End If

The compiler gives me the following error:

B4X:
javac 1.7.0_75
main.java:6586: error: cannot find symbol
public static boolean isMockLocationSettingsON(Context context) {
                                               ^
  symbol:   class Context
  location: class main

Is there something missing?
 
Top