理解TelephonyProvider与应用ApnEditor的关系

TelephonyProvider 所在AndroidManifest 的配置packages/providers/TelephonyProvider/AndroidManifest.xml

具体提供了apn的数据库的创建,表的创建,增删更新删除等操作。

<provider android:name="TelephonyProvider"
              android:authorities="telephony"
              android:exported="true"
              android:multiprocess="false" />

匹配的MIMETYPE类型

@Override


publicString getType(Uriurl)

{

switch(s_urlMatcher.match(url)){

caseURL_TELEPHONY:

caseURL_TELEPHONY_USING_SUBID:

return"vnd.android.cursor.dir/telephony-carrier";


caseURL_ID:

return"vnd.android.cursor.item/telephony-carrier";


caseURL_PREFERAPN_USING_SUBID:

caseURL_PREFERAPN_NO_UPDATE_USING_SUBID:

caseURL_PREFERAPN:

caseURL_PREFERAPN_NO_UPDATE:

return"vnd.android.cursor.item/telephony-carrier";


default:

thrownewIllegalArgumentException("UnknownURL " + url);

}

}



用的位置:packages/apps/Settings/src/com/android/settings/ApnSettings.java


privatevoidaddNewApn() {

Intentintent = newIntent(Intent.ACTION_INSERT, Telephony.Carriers.CONTENT_URI);

intsubId = mSubscriptionInfo!= null? mSubscriptionInfo.getSubscriptionId()

:SubscriptionManager.INVALID_SUBSCRIPTION_ID;

intent.putExtra("sub_id",subId);

startActivity(intent);

}


@Override

publicbooleanonPreferenceTreeClick(PreferenceScreenpreferenceScreen, Preference preference) {

intpos = Integer.parseInt(preference.getKey());

Uri url =ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);

startActivity(newIntent(Intent.ACTION_EDIT, url));

returntrue;

}

位置:

packages/apps/Settings/src/com/android/settings/ApnEditor.java

if(action.equals(Intent.ACTION_EDIT)) {

mUri= intent.getData();

} elseif(action.equals(Intent.ACTION_INSERT)) {

if(mFirstTime|| icicle.getInt(SAVED_POS)== 0) {

mUri= getContentResolver().insert(intent.getData(), newContentValues());

} else{

mUri= ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI,

icicle.getInt(SAVED_POS));

}


配置文件:



<activityandroid:name="ApnEditor"

android:label="@string/apn_edit">

<intent-filter>

<actionandroid:name="android.intent.action.VIEW"/>

<actionandroid:name="android.intent.action.EDIT"/>

<categoryandroid:name="android.intent.category.DEFAULT"/>

<dataandroid:mimeType="vnd.android.cursor.item/telephony-carrier"/>

</intent-filter>


<intent-filter>

<actionandroid:name="android.intent.action.INSERT"/>

<categoryandroid:name="android.intent.category.DEFAULT"/>

<dataandroid:mimeType="vnd.android.cursor.dir/telephony-carrier"/>

</intent-filter>

</activity>


可以在此文件中通过

Cursorcursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI,newString[] {

"_id","name","apn","type"},where, null,

Telephony.Carriers.DEFAULT_SORT_ORDER);


getContentResolver来调用TelephonyProvider的相关数据库的接口。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值