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 String getApnPort(Context context) {
        Cursor c = context.getContentResolver().query(PREFERRED_APN_URI, null, null, null, null);
        c.moveToFirst();
        if (c.isAfterLast()) {
            c.close();
            return "80";
        }

        String port = null;
        port = c.getString(c.getColumnIndex(APN_PROP_PORT));
        if (port == null) {
            c.close();
            port = "80";
        }
        c.close();
        return port;
    }
}