77范文网 - 专业文章范例文档资料分享平台

Android APN开发流程分析(5)

来源:网络收集 时间:2019-04-23 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

{

resolver.update(PREFERRED_APN_URI, values, null, null);

Cursor c = resolver.query(PREFERRED_APN_URI, new String[] { \\ if (c != null) {

res = true; c.close(); } }

catch (SQLException e) { }

return res; }

public void SetDefaultAPN(int id) {

setDefaultApn(id); ConnectivityManager cm = (ConnectivityManager) this.getSystemService(CONNECTIVITY_SERVICE);

cm.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, \ Cursor cursor = getContentResolver().query(PREFERRED_APN_URI, null, null, null, null);

int rows = cursor.getCount(); cursor.moveToFirst(); String apn;

for (int i = 0; i < rows; i++) {

apn = cursor.getString(1);

Log.e(\ cursor.moveToNext(); } }

//检查指定APN是否存在 public int checkAPN() {

ApnNode checkApn = new ApnNode(); checkApn.setName(\中国电信ctnet\ checkApn.setApn(\ checkApn.setMcc(getMCC());

checkApn.setMnc(getMNC());

checkApn.setNumeric(getSimOperator()); return isApnExisted(checkApn); }

public int isApnExisted(ApnNode apnNode) {

int apnId = -1;

// Uri uri = Uri.parse(\

Cursor mCursor = getContentResolver().query(APN_TABLE_URI, null, null, null, null);

while (mCursor != null && mCursor.moveToNext()) {

apnId = mCursor.getShort(mCursor.getColumnIndex(\

String name = mCursor.getString(mCursor.getColumnIndex(\ String apn = mCursor.getString(mCursor.getColumnIndex(\ String type = mCursor.getString(mCursor.getColumnIndex(\ String proxy = mCursor.getString(mCursor.getColumnIndex(\ String port = mCursor.getString(mCursor.getColumnIndex(\ String current = mCursor.getString(mCursor.getColumnIndex(\

String mcc = mCursor.getString(mCursor.getColumnIndex(\ String mnc = mCursor.getString(mCursor.getColumnIndex(\ String numeric = mCursor.getString(mCursor.getColumnIndex(\

Log.e(\+ type + \

if (/*apnNode.getName().equals(name)*/(apnNode.getApn().equals(apn) && apnNode.getMcc().equals(mcc) && apnNode.getMnc().equals(mnc) && apnNode.getNumeric().equals(numeric)) && (type == null || \|| \(apnNode.getApn().equals(apn) && \ {

return apnId; } else {

apnId = -1; } }

return apnId; }

public int addNewApn(ApnNode apnNode)

{

int apnId = -1;

ContentResolver resolver = getContentResolver(); ContentValues values = new ContentValues(); values.put(\ values.put(\ values.put(\ values.put(\ values.put(\

values.put(\ values.put(\ values.put(\

values.put(\

// Note: this values need to be update, and for now, it only for XT800.

Cursor c = null; try {

Uri newRow = resolver.insert(APN_TABLE_URI, values); if (newRow != null) {

c = resolver.query(newRow, null, null, null, null);

int idindex = c.getColumnIndex(\ c.moveToFirst();

apnId = c.getShort(idindex);

Log.d(\\ID: \+ apnId + \Inserting new APN succeeded!\ } }

catch (SQLException e) { }

if (c != null) c.close();

return apnId; }

//添加一个APN

private void InsetAPN() {

ApnNode checkApn = new ApnNode();

checkApn.setName(\中国电信CTNET\ checkApn.setApn(\

// checkApn.setProxy(\// checkApn.setPort(\ checkApn.setUser(\

checkApn.setPassword(\ checkApn.setMcc(getMCC()); checkApn.setMnc(getMNC());

checkApn.setNumeric(getSimOperator()); apnd_id = addNewApn(checkApn); } }

4.主界面的xml文件为:

android:id=\

android:layout_width=\android:layout_height=\android:orientation=\

xmlns:android=\>

只要是开发过android的肯定清楚这些代码和界面吧,我也不多解释了,如果哥们你看不懂,那就是说明你还没弄清android开发,先去补补课再来看

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/napolun007/archive/2010/07/20/5748595.aspx

网络连接实例(接上篇APN设置) 收藏

private static final String WEBURL = \

try {

// 创建URL对象

URL url = new URL(WEBURL); // 创建URL连接 HttpURLConnection connection = (HttpURLConnection)url.openConnection();

// 对于 HTTP 连接可以直接转换成 HttpURLConnection,

// 这样就可以使用一些 HTTP 连接特定的方法,如 setRequestMethod() 等

// HttpURLConnection connection

// =(HttpURLConnection)url.openConnection(Proxy_yours); // 设置参数

connection.setConnectTimeout(10000); // 连接服务器

connection.connect();

} catch (IOException e) {

// TODO Auto-generated catch block e.printStackTrace(); }

连接Intenet网络,进行APN设置后无法直接进入网络,可以先进行下此项连接设置,就能登录网络了

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/napolun007/archive/2010/07/21/5753018.aspx

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库Android APN开发流程分析(5)在线全文阅读。

Android APN开发流程分析(5).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/622189.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: