开关Android的APN网络的实现
2010-08-21 06:20:00 来源:WEB开发网import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
/**
* 呃彦是Activity
* @author SinFrancis wong
* @site http://mdev.cc
* @wiki http://mdev.cc/wiki
* @since 2010-01-08
*/
public class Main extends Activity {
/** Called when the activity is first created. */
Uri uri = Uri.parse("content://telephony/carriers");
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button open= (Button) findViewById(R.id.open);
Button close= (Button) findViewById(R.id.close);
open.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openAPN();
}
});
close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
closeAPN();
}
});
}
public void openAPN(){
List list = getAPNList();
for (APN apn : list) {
ContentValues cv = new ContentValues();
cv.put("apn", APNMatchTools.matchAPN(apn.apn));
cv.put("type", APNMatchTools.matchAPN(apn.type));
getContentResolver().update(uri, cv, "_id=?", new String[]{apn.id});
}
}
public void closeAPN(){
List list = getAPNList();
for (APN apn : list) {
ContentValues cv = new ContentValues();
赞助商链接