Android Question Problem with Java inline code.

Discussion in 'Android Questions' started by vfafou, Mar 28, 2015.

  1. vfafou

    vfafou Active Member Licensed User

    Hello!
    I'm trying to compile my app with these two functions:

    Code:
    #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:

    Code:
    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?
     
  2. warwound

    warwound Expert Licensed User

    You need to import the various jave classes that your inline java uses.
    That requires you to use the java import command.
     
    vfafou and thedesolatesoul like this.
  3. vfafou

    vfafou Active Member Licensed User

    Thank you very much warwound! It works like a charm!!!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice