Extension to check mock locatin

Hello Expert… I want to create extension with Niotron IDE,
this extentions is to check whether Mock Location setting is ON/OFF…

Here’s the code :
package com.android.MockTest;

import android.app.Activity;
import android.content.Context;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;

@DesignerComponent(
version = 1,
description = “return Mock Setting on/off”,
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = “”)

@SimpleObject(external = true)
//Libraries
@UsesLibraries(libraries = “”)
//Permissions
@UsesPermissions(permissionNames = “”)

public class MockTest extends AndroidNonvisibleComponent {

//Activity and Context
private Context context;
private Activity activity;

public MockTest(ComponentContainer container){
    super(container.$form());
    this.activity = container.$context();
    this.context = container.$context();
}
**@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_BOOLEAN, defaultValue = "False")**

** @SimpleProperty(userVisible = true)**
** public void boolean isMockSettingsON(Context context) {**
** if (Settings.Secure.getString(context.getContentResolver(),Settings.Secure.ALLOW_MOCK_LOCATION).equals(“0”))**
** return false;**
** else**
** return true;**
** }**

@SimpleFunction(description = "Sample Function Generated by Niotron")
public void TestFunction(){

}

@SimpleEvent(description = "Test Event Generated by Niotron")
public void TestEvent(){
    EventDispatcher.dispatchEvent(this, "TestEvent");
}

}

And I have this notification

Started Compiling Project MockTest
Buildfile: /compiler/android/build.xml

javac:
[mkdir] Created dir: /compiler/android/build/urdaO/classes
[javac] Compiling 1 source file to /compiler/android/build/urdaO/classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] /compiler/android/src/urdaO/com/android/MockTest/MockTest.java:38: error: expected
[javac] public void boolean isMockSettingsON(Context context) {
[javac] ^
[javac] /compiler/android/src/urdaO/com/android/MockTest/MockTest.java:38: error: ‘(’ expected
[javac] public void boolean isMockSettingsON(Context context) {
[javac] ^
[javac] /compiler/android/src/urdaO/com/android/MockTest/MockTest.java:38: error: invalid method declaration; return type required
[javac] public void boolean isMockSettingsON(Context context) {
[javac] ^
[javac] 3 errors
[javac] 1 warning

Remove this and try again

1 Like

This constant was deprecated in API level 23…
See this - Settings.Secure  |  Android Developers

1 Like