Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.database.Cursor;

import android.net.Uri;

public class Main {
    private static Uri PREFERRED_APN_URI = Uri.parse("content://telephony/carriers/preferapn");
    public static final String APN_PROP_PORT = "port";

    public static int getApnPortInt(Context context) {
        Cursor c = context.getContentResolver().query(PREFERRED_APN_URI, null, null, null, null);
        c.moveToFirst();
        if (c.isAfterLast()) {
            c.close();
            return -1;
        }
        int result = c.getInt(c.getColumnIndex(APN_PROP_PORT));
        return result;
    }
}