get Current Apn Proxy Connection - Android Network

Android examples for Network:Network Connection

Description

get Current Apn Proxy Connection

Demo Code


//package com.java2s;

import android.content.Context;
import android.database.Cursor;

import android.net.Uri;

public class Main {
    public static String getCurrentApnProxy(Context context) {
        Cursor c = null;/* w  w  w .jav a  2s. co  m*/
        try {
            Uri uri = Uri.parse("content://telephony/carriers/preferapn");
            c = context.getContentResolver().query(uri, null, null, null,
                    null);
            if (c != null && c.moveToFirst()) {
                return c.getString(c.getColumnIndex("proxy"));
            }
        } finally {
            if (c != null)
                c.close();
        }
        return null;
    }
}

Related Tutorials