使用Java的Read联系人扩展

时间:2019-07-18 06:48:23

标签: java arrays

我想为App Inventor平台创建扩展名(aix)以读取联系人并将其存储为列表。需要稍微修改一下Java中读取联系人的简单代码才能创建此扩展 我附上示例扩展,以概述App Inventor扩展。您可以阅读http://ai2.appinventor.mit.edu/reference/other/extensions.html中的文档 感谢您的帮助

package com.Pitagoras;


import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.util.MediaUtil;
import com.google.appinventor.components.runtime.*;

@DesignerComponent(version = Pitagoras.VERSION,
    description = "Teorema de Pitagoras. " + "Juan Antonio Villalpando - KIO4.COM ",
    category = ComponentCategory.EXTENSION,
    nonVisible = true,
    iconName = "")
@SimpleObject(external = true)
public class Pitagoras extends AndroidNonvisibleComponent implements Component {

public static final int VERSION = 1;
public static final float DEFAULT_CATETO_A = 3f;
public static final float DEFAULT_CATETO_B = 4f;
private ComponentContainer container;
private double cateto_a = 0;
private double cateto_b = 0;

public Pitagoras(ComponentContainer container) {
    super(container.$form());
    this.container = container;
    Cateto_A(DEFAULT_CATETO_A);
    Cateto_B(DEFAULT_CATETO_B);
}

// Creacion de las Propiedades.
@SimpleProperty(
    category = PropertyCategory.BEHAVIOR)
public double Cateto_A() {
    return cateto_a;
}

 @SimpleProperty(
    category = PropertyCategory.BEHAVIOR)
public double Cateto_B() {
    return cateto_b;
}

// Establecimiento de las Propiedades.
@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_NON_NEGATIVE_FLOAT, defaultValue = Pitagoras.DEFAULT_CATETO_A + "")
@SimpleProperty(description = "Asigna el valor del cateto A. " +  "El separador decimal es el punto.")
public void Cateto_A(double nuevoCateto_A) {
    this.cateto_a = nuevoCateto_A;
}

@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_NON_NEGATIVE_FLOAT, defaultValue = Pitagoras.DEFAULT_CATETO_B + "")
@SimpleProperty(description = "Asigna el valor del cateto B. " +  "El separador decimal es el punto.")
public void Cateto_B(double nuevoCateto_B) {
    this.cateto_b = nuevoCateto_B;
}

// Funcion para calcular la hipotenusa.
@SimpleFunction(description = "Introduce los dos catetos y obtendras la hipotenusa.")
public double Pitagoras(double catetoA, double catetoB) {
    double hipotenusa, cuadrado;

    hipotenusa = Math.sqrt((catetoA*catetoA)+(catetoB*catetoB));
    cuadrado = hipotenusa * hipotenusa;  // Calcula el cuadrado de la hipotenusa.

   YaCalculada(cuadrado); 

    return hipotenusa;
}

// Bloque disponible despues de calcular la hipotenusa.
@SimpleEvent(description = "Muestra la hipotenusa al cuadrado.")
public void YaCalculada(double sucuadrado){
    EventDispatcher.dispatchEvent(this, "YaCalculada", sucuadrado);
}    

}

上面的代码是转换为aix的java文件,在创建此java代码时需要帮助

0 个答案:

没有答案