Example usage for android.telephony SignalStrength getClass

List of usage examples for android.telephony SignalStrength getClass

Introduction

In this page you can find the example usage for android.telephony SignalStrength getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.restcomm.app.utillib.ContentProvider.ContentValuesGenerator.java

private static String listSignalFields(SignalEx mmcsignal) {
    int i;//from  ww w .  ja  va  2s .  co m
    String strSignals = "";
    if (mmcsignal != null && mmcsignal.getSignalStrength() != null) {

        SignalStrength signalStrength = (SignalStrength) mmcsignal.getSignalStrength();

        Field[] fields = null;
        try {
            fields = signalStrength.getClass().getDeclaredFields();

            for (i = 0; i < fields.length; i++) {
                fields[i].setAccessible(true);
                //if (!fields[i].getName().equals("CREATOR") && !fields[i].getName().equals("LOG_TAG") &&
                //      fields[i].getName().indexOf("INVALID") == -1 && fields[i].getName().indexOf("STRENGTH") == -1)
                if (fields[i].getName().toLowerCase().substring(0, 1)
                        .equals(fields[i].getName().substring(0, 1))) {
                    try {
                        strSignals += fields[i].getName() + "=";
                        if (fields[i].get(signalStrength) != null)
                            strSignals += fields[i].get(signalStrength).toString() + ",";
                        else
                            strSignals += "null";
                    } catch (Exception e) {
                        LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, "", "listSignalFields", "exception", e);
                    }
                }
            }
        } catch (SecurityException e) {
            LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, "", "listSignalFields", "SecurityException", e);
        } catch (Exception e) {
            LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, "", "listSignalFields", "exception", e);
        }
    }
    return strSignals;
}