You can set APN proxy using something similar to this.

 public int InsertAPN(String name, String apn_addr)
    {
        int id = -1;
                ContentResolver resolver = this.getContentResolver();
        ContentValues values = new ContentValues();
        values.put("name", name);
        values.put("apn", apn_addr);
         final Uri APN_TABLE_URI =
            Uri.parse("content://telephony/carriers");
        /*
         * The following three field values are for testing in Android
emulator only
         * The APN setting page UI will ONLY display APNs whose
'numeric' filed is
         * TelephonyProperties.PROPERTY_SIM_OPERATOR_NUMERIC.
         * On Android emulator, this value is 310260, where 310 is
mcc, and 260 mnc.
         * With these field values, the newly added apn will appear in
system UI.*/

        values.put("mcc", "310");
        values.put("mnc", "260");
        values.put("numeric", "310260");
        values.put("proxy","10.102.24.60");
        Uri newRow = resolver.insert(APN_TABLE_URI, values);
        Cursor c = null;
            try
        {

           if(newRow != null)
            {
                c = resolver.query(newRow, null, null, null, null);
                Log.d("Krishna", "Newly added APN:");
              //  printAllData(c); //Print the entire result set

                // Obtain the apn id
                int idindex = c.getColumnIndex("_id");
                c.moveToFirst();
                id = c.getShort(idindex);
                Log.d("Krishna", "New ID: " + id + ": Inserting new
APN succeeded!");
            }
        }
        catch(SQLException e)
        {
            Log.d("Krishna", e.getMessage());
        }

        if(c !=null )
            c.close();
        return id;
    }

On Dec 30 2011, 11:30 am, Arka Sharma <[email protected]>
wrote:
> On Dec 29, 9:38 am, kris <[email protected]> wrote:
>
> > You cannot set a globalproxyas you noticed that it is denied with
> > permission. Only apps that are signed with the same certificate of the
> > firmware can set theproxy(permission level 3).
>
> > One thing that you can do is to set a per connection basedproxy. You
> > can setproxyseparately forWIFIand APN also. Under advanced setting
> > inWIFIyou setWIFIproxyand for APN you already know as you did in
> > emulator.
>
> > Hope this helps.
>
> > Thanks
> > Krishna
>
> Thanks Krishna for your help.Now can I set the httpproxyfrom code ?
> I mean what I do from APN settings is it possible to do from a piece
> of code ? I tried inserting http_proxy row in system table,I tried
> with System.puutString and Secure.putString all failed.
>
> Let me explain the requirement thoroughly.One service will be there
> which will be periodically monitoring the MCCMNC.When user is in local
> network the first 5 digit of IMSI will be same as the MCCMNC.When
> first 5 digit of IMSI is different from MCCMNC theproxyconfiguration
> for APN will be done.
>
> Thanks & Regards,
> Arka

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to