欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android如何設(shè)置小區(qū)廣播默認(rèn)信道(50與60并支持雙卡)

 更新時(shí)間:2013年06月02日 15:28:27   作者:  
置小區(qū)廣播默認(rèn)信道50與60,并支持雙卡主要是印度市場(chǎng),具體的實(shí)現(xiàn)如下,感興趣的朋友可以參考下哈
要求設(shè)置默認(rèn)信道50與60,并支持雙卡。

在PhoneApp.java文件中增加code:

在文件開(kāi)頭部分import 包:
復(fù)制代碼 代碼如下:

import android.provider.Telephony;
import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
import android.content.ContentValues;
import android.database.Cursor;

2.在文件開(kāi)頭部分增加變量:
復(fù)制代碼 代碼如下:

private final BroadcastReceiver mSmsReadyReceiver = new SmsReadyBroadcastReceiver();
private static final int MESSAGE_SET_STATE = 33;
private static final int MESSAGE_SET_CONFIG = 32;
private static final String KEYID = "_id";
private static final String NAME = "name";
private static final String NUMBER = "number";
private static final String ENABLE = "enable";
private static final Uri CHANNEL_URI = Uri.parse("content://cb/channel");
private static final Uri CHANNEL_URI1 = Uri.parse("content://cb/channel1");

3.在mHandeler中增加Case:
復(fù)制代碼 代碼如下:

case MESSAGE_SET_STATE:
handleSetStateResponse(msg);
break;

4.在oncreate函數(shù)中注冊(cè)cellbroadcastRecivier:
復(fù)制代碼 代碼如下:

IntentFilter smsReadyIntentFilter = new IntentFilter("android.provider.Telephony.SMS_STATE_CHANGED");
registerReceiver(mSmsReadyReceiver,smsReadyIntentFilter);

5.在類(lèi)中增加函數(shù):
復(fù)制代碼 代碼如下:

private class SmsReadyBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent){
Log.e("kpp","Sms Ready!!");
String action = intent.getAction();
Log.e("kpp","Sms Ready action ="+action);
if (action.equals("android.provider.Telephony.SMS_STATE_CHANGED")) {
int extra = intent.getIntExtra("simId",0);
boolean isReady = intent.getBooleanExtra("ready",false);
Log.e("kpp","Sms Ready extra ="+extra);
Log.e("kpp","Sms Ready isReady ="+isReady);
if(!isReady){
return;
}
Message msg;
msg = mHandler.obtainMessage(MESSAGE_SET_STATE, extra, MESSAGE_SET_STATE,null);

if (FeatureOption.MTK_GEMINI_SUPPORT == true)
{
((GeminiPhone)phone).activateCellBroadcastSmsGemini(0,msg, extra);
}
else
{
phone.activateCellBroadcastSms(0,msg);
}
}
}
}


private void handleSetStateResponse(Message msg) {
int simId = msg.arg1;
if (msg.arg2 == MESSAGE_SET_STATE) {
AsyncResult ar = (AsyncResult) msg.obj;
if (ar == null) {
Log.i(LOG_TAG, "handleSetStateResponse,ar is null");
return;
}
if (ar.exception != null) {
if (DBG)
Log.d(LOG_TAG, "handleSetStateResponse: ar.exception="+ ar.exception);
} else {
Log.i(LOG_TAG, "handleSetStateResponse: re get ok");
addCustomChanneltoList(PhoneConstants.GEMINI_SIM_1,"Channel1",50);
addCustomChanneltoList(PhoneConstants.GEMINI_SIM_1,"Channel2",60);
addCustomChanneltoList(PhoneConstants.GEMINI_SIM_2,"Channel1",50);
addCustomChanneltoList(PhoneConstants.GEMINI_SIM_2,"Channel2",60);
}
}
}

private void addCustomChanneltoList(int mSimId,String channelName,int channelNum){
Log.d(LOG_TAG, "addCustomChanneltoList: mSimId=" + mSimId
+ ", channelName= " + channelName + ", channelNum= " + channelNum);
if(queryChannelFromDatabase(mSimId,channelName,channelNum)){
SmsBroadcastConfigInfo[] objectList = new SmsBroadcastConfigInfo[1];
objectList[0] = new SmsBroadcastConfigInfo(channelNum,channelNum, -1, -1, true);
Message msg1 = mHandler.obtainMessage(MESSAGE_SET_CONFIG, 0,MESSAGE_SET_CONFIG, null);
if (FeatureOption.MTK_GEMINI_SUPPORT == true)
{
((GeminiPhone)phone).setCellBroadcastSmsConfigGemini(objectList, objectList, msg1, mSimId);

}
else
{
phone.setCellBroadcastSmsConfig(objectList, objectList, msg1);
}
}
}

private boolean queryChannelFromDatabase(int mSimId,String channelName,int channelNum){
// ClearChannel();
Log.d(LOG_TAG, "queryChannelFromDatabase: mSimId=" + mSimId
+ ", channelName= " + channelName + ", channelNum= " + channelNum);
String[] projection = new String[] { KEYID, NAME, NUMBER, ENABLE };
String SELECTION = "(" + NUMBER + " = " + channelNum + ")";
Cursor cursor = null;
if(mSimId==PhoneConstants.GEMINI_SIM_1){
cursor = this.getContentResolver().query(CHANNEL_URI,projection, SELECTION, null, null);
}else if(mSimId==PhoneConstants.GEMINI_SIM_2){
cursor = this.getContentResolver().query(CHANNEL_URI1,projection, SELECTION, null, null);
}

if (cursor.getCount() == 0){
ContentValues values = new ContentValues();
values.put(NAME,channelName);
values.put(NUMBER, channelNum);
values.put(ENABLE, true);
try {
if(mSimId==PhoneConstants.GEMINI_SIM_1){
this.getContentResolver().insert(CHANNEL_URI, values);
}else if(mSimId==PhoneConstants.GEMINI_SIM_2){
this.getContentResolver().insert(CHANNEL_URI1, values);
}
} catch (Exception e){
return false;
}
}
cursor.close();
return true;
}

相關(guān)文章

  • 深入理解Android之接口回調(diào)機(jī)制

    深入理解Android之接口回調(diào)機(jī)制

    本篇文章主要介紹了Android之接口回調(diào)機(jī)制,在開(kāi)發(fā)中經(jīng)常會(huì)用到,具有一定的學(xué)習(xí)價(jià)值,有需要的可以來(lái)了解一下。
    2016-10-10
  • Android實(shí)現(xiàn)雙曲線折線圖

    Android實(shí)現(xiàn)雙曲線折線圖

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)雙曲線折線圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-09-09
  • Android 應(yīng)用的安裝過(guò)程詳解

    Android 應(yīng)用的安裝過(guò)程詳解

    這篇文章主要介紹了Android 應(yīng)用的安裝過(guò)程詳解的相關(guān)資料,對(duì)應(yīng)Android應(yīng)用的安裝,我想大家應(yīng)該了解下的,需要的朋友可以參考下
    2016-11-11
  • Android實(shí)現(xiàn)簡(jiǎn)單旋轉(zhuǎn)動(dòng)畫(huà)

    Android實(shí)現(xiàn)簡(jiǎn)單旋轉(zhuǎn)動(dòng)畫(huà)

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)簡(jiǎn)單旋轉(zhuǎn)動(dòng)畫(huà),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • Flutter實(shí)現(xiàn)資源下載斷點(diǎn)續(xù)傳的示例代碼

    Flutter實(shí)現(xiàn)資源下載斷點(diǎn)續(xù)傳的示例代碼

    在項(xiàng)目開(kāi)發(fā)中,特別是C端的產(chǎn)品,資源下載實(shí)現(xiàn)斷點(diǎn)續(xù)傳是非常有必要的。今天我們不講過(guò)多原理的知識(shí),分享下簡(jiǎn)單實(shí)用的資源斷點(diǎn)續(xù)傳
    2022-07-07
  • Flutter中如何實(shí)現(xiàn)無(wú)Context跳轉(zhuǎn)詳解

    Flutter中如何實(shí)現(xiàn)無(wú)Context跳轉(zhuǎn)詳解

    這篇文章主要給大家介紹了關(guān)于Flutter中如何實(shí)現(xiàn)無(wú)Context跳轉(zhuǎn)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Flutter具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • Android使用view仿支付寶月賬單

    Android使用view仿支付寶月賬單

    這篇文章主要為大家詳細(xì)介紹了Android使用view仿支付寶月賬單,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-04-04
  • Android中自定義加載樣式圖片的具體實(shí)現(xiàn)

    Android中自定義加載樣式圖片的具體實(shí)現(xiàn)

    想實(shí)現(xiàn)下面這張圖中的自定義加載樣式,其實(shí)很簡(jiǎn)單,首先我們需要的布局組件有ProcessBar和TextView,下面是布局文件的代碼
    2014-04-04
  • Android背景圖下拉回彈效果實(shí)例

    Android背景圖下拉回彈效果實(shí)例

    大家好,本篇文章主要講的是Android背景圖下拉回彈效果實(shí)例,感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話記得收藏一下
    2022-01-01
  • android實(shí)現(xiàn)用戶(hù)體驗(yàn)超棒的微信WebView進(jìn)度條

    android實(shí)現(xiàn)用戶(hù)體驗(yàn)超棒的微信WebView進(jìn)度條

    本篇文章主要介紹了android實(shí)現(xiàn)用戶(hù)體驗(yàn)超棒的微信WebView進(jìn)度條,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-03-03

最新評(píng)論