get Current Apn Proxy from telephony - Android Network

Android examples for Network:Proxy

Description

get Current Apn Proxy from telephony

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 cur = null;//from ww w  .  j av a  2 s  . c o m
        try {
            Uri uri = Uri.parse("content://telephony/carriers/preferapn");
            cur = context.getContentResolver().query(uri, null, null, null,
                    null);
            if ((cur != null) && (cur.moveToFirst())) {
                String str = cur.getString(cur.getColumnIndex("proxy"));
                return str;
            }
        } finally {
            if (cur != null)
                cur.close();
        }
        return null;
    }
}

Related Tutorials