Android Question Problem with Java inline code.

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

  1. vfafou

    vfafou Active Member Licensed User

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

    #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

      for (ApplicationInfo applicationInfo : packages) {
       try {
        PackageInfo packageInfo = pm.getPackageInfo(

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

        if (requestedPermissions != null) {
         for (int i = 0; i < requestedPermissions.length; i++) {
          if (requestedPermissions[i]
            && !applicationInfo.packageName.equals(context
              .getPackageName())) {
       } catch (NameNotFoundException e) {
      return mockPermissionApps;
    #End If
    The compiler gives me the following error:

    javac 1.7.0_75
    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!!!
  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