編輯:關於Android編程
android4.0之後,需要系統簽名,並把apk放在system/app下面
[html]
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
</uses-permission>
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS" >
</uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
</uses-permission>
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS" >
</uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
[java]
package com.lenovo.testapn;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.Menu;
public class MainActivity extends Activity {
private static final String TAG = "MainActivity";
public static final Uri APN_URI = Uri.parse("content://telephony/carriers");
// public static final Uri PREFERRED_APN_URI
// =Uri.parse("PREFERRED_APN_URI PREFERRED_APN_URI ");
public static final Uri CURRENT_APN_URI = Uri
.parse("content://telephony/carriers/preferapn");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(TAG, "onCreate");
checkAPN();
// SetAPN(addAPN());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
public void checkAPN() {
// 檢查當前連接的APN
Cursor cr = getContentResolver().query(APN_URI, null, null, null, null);
Log.d(TAG, "cr" + cr);
while (cr != null && cr.moveToNext()) {
// if(cr.getString(cr.getColumnIndex("_id")))
// APN id
String id = cr.getString(cr.getColumnIndex("_id"));
Log.d(TAG, "id" + id);
// String apn_id= cr.getString(cr.getColumnIndex("apn_id"));
//
// Log.d(TAG, "apn_id" + apn_id);
// APN name
String apn = cr.getString(cr.getColumnIndex("apn"));
Log.d(TAG, apn);
// Toast.makeText(getApplicationContext(),
// "當前 id:" + id + " apn:" + apn, Toast.LENGTH_LONG).show();
}
}
// 新增一個cmnet接入點
public int addAPN() {
int id = -1;
Log.d(TAG, "添加一個新的apn");
String NUMERIC = getSIMInfo();
Log.d(TAG, "NUMERIC" + NUMERIC);
if (NUMERIC == null) {
return -1;
}
ContentResolver resolver = this.getContentResolver();
ContentValues values = new ContentValues();
SIMCardInfo siminfo = new SIMCardInfo(MainActivity.this);
// String user = siminfo.getNativePhoneNumber().substring(start);
values.put("name", "專用APN"); // apn中文描述
values.put("apn", "myapn"); // apn名稱
values.put("type", "default,supl");
values.put("numeric", NUMERIC);
values.put("mcc", NUMERIC.substring(0, 3));
values.put("mnc", NUMERIC.substring(3, NUMERIC.length()));
values.put("proxy", "");
values.put("port", "");
values.put("mmsproxy", "");
values.put("mmsport", "");
values.put("user", "");
values.put("server", "");
values.put("password", "");
values.put("mmsc", "");
Cursor c = null;
Uri newRow = resolver.insert(APN_URI, values);
if (newRow != null) {
c = resolver.query(newRow, null, null, null, null);
int idIndex = c.getColumnIndex("_id");
c.moveToFirst();
id = c.getShort(idIndex);
}
if (c != null)
c.close();
return id;
}
protected String getSIMInfo() {
TelephonyManager iPhoneManager = (TelephonyManager) this
.getSystemService(Context.TELEPHONY_SERVICE);
return iPhoneManager.getSimOperator();
}
// 設置接入點
public void SetAPN(int id) {
ContentResolver resolver = this.getContentResolver();
ContentValues values = new ContentValues();
values.put("apn_id", id);
resolver.update(CURRENT_APN_URI, values, null, null);
// resolver.delete(url, where, selectionArgs)
}
}
webservice 的概念 webservice 就是一個應用程序,它提供一種通過web方式訪問的api.解決兩個系統或者(應用程序)
流行的應用的導航一般分為兩種,一種是底部導航,一種是側邊欄。說明IDE:AS,Android studio;模擬器:genymotion;實現的效果,見下圖。具體實現為了
上一篇Android中XUtils3框架使用方法詳解(一)文章,主要介紹了XUtil3的注解模塊,網絡模塊,圖片加載模塊,今天給大家帶來數據庫模塊的講解,現在主流的ORM
本片博客主要簡介以下Android兩個問題介紹一下常見的內存緩存算法 怎樣實現這些Android算法大家應該對ImageLoader這個框架都不陌生吧,一個很強大的圖片加