一 : 程序员培训计划
程序员培训计划
培训目标: 了解XX公司的历史和企业文化,规章制度等 了解XX公司产品主要应用和项目管理的基本知识
掌握XX产品的基本业务流程 掌握XX技术开发的基本技能 培训对象: XXX
培训时间: 20XX年10月26日---11月11日。
新进程序员 1周业务培训,1周集中培训,8周On Job Training。
指导老师: XX\ XX\XX\XX
二 : 程序员培训计划
程序员培训计划
培训目标: 了解XX公司的历史和企业文化,规章制度等 了解XX公司产品主要应用和项目管理的基本知识
掌握XX产品的基本业务流程 掌握XX技术开发的基本技能 培训对象: XXX
培训时间: 20XX年10月26日---11月11日。(www.61k.com)
新进程序员 1周业务培训,1周集中培训,8周On Job Training。
指导老师: XX\ XX\XX\XX
三 : 高级程序员修炼之道-Android培训系列课程之BroadCastReceiver1
??????????????????-Android??????????????BroadCastReceiver
Android????BroadCastReceiver??
BroadCastReceiver??????????framework/base/core/java/android.content.BroadcastReceiver.java ????????????BroadcastReceiver??????????????Intent??????Intent????????????????
Context.sendBroadcast()??Context.sendOrderedBroadcast()??????????????????????Intent??????????????Intent????????????????????????
????????????????????????????????????????????????????BroadcastReceiver????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????
BroadcastReceiver??????????????????????????????????????????????????BroadcastReceiver????????Activity??????????????????NotificationMananger??????????????????Service??????
BroadCastReceiver????????
1.??????
?? Android ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
2.??????
????????????????
??????????????????????????????????http://www.toceansoft.com 1/10
registerreceiver 高级程序员修炼之道-Android培训系列课程之BroadCastReceiver1
??????????????????-Android??????????????BroadCastReceiver
????????????
????
public class MyBroadcastReceiver extends BroadcastReceiver {
// action????
String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(SMS_RECEIVED)) {
// ????????:??????????????????????????????
}
}
}
????????????AndroidManifest.xml??????
<receiver android:name=".MyBroadcastReceiver">
<intent-filter android:priority="1000">
<action android:name=" android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>????????????????
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
????????????
// ??????????-??????????
privatenewBroadcastReceiver() {
@Override
??????????????????????????????????http://www.toceansoft.com 2/10
registerreceiver 高级程序员修炼之道-Android培训系列课程之BroadCastReceiver1
??????????????????-Android??????????????BroadCastReceiver
public void onReceive(Context context, Intent intent) {
//????????????????????????????????????
}
};
????????????
IntentFilter intentFilter = new IntentFilter("android.provider.Telephony.SMS_RECEIVED ");
registerReceiver(mBatteryInfoReceiver, intentFilter);
3.??????????
??????Android ??????????????????????????????Activity ????????????????????????????????
????????????????????????????onReceive()????????????????????????????????
??????????????,??????????BroadcastReceiver????,????????onReceive()????,??????????,??????????????.??onReceive()??????10??????????????????Android??????????????????.??????
BroadcastReceiver??????????????????????????,??????????ANR(Application No
Response)????????.????????????
????????BroadcastReceiver??
??????????????????????????????????http://www.toceansoft.com 3/10
registerreceiver 高级程序员修炼之道-Android培训系列课程之BroadCastReceiver1
??????????????????-Android??????????????BroadCastReceiver
??????????????????????????????,????????????Intent??Service,??Service??????.????????????????????????,????BroadcastReceiver??????????????,????????????????????
BroadcastReceiver??????????.BroadcastReceiver????????,????BroadcastReceiver??
????????????????????????????????????????,????????????????(??????????????????????).??????????????????????,??????????????????????????????.??????????????????????????????.
??????????????????????
??????????
????????(Normal broadcasts)
61阅读提醒您本文地址:
????????????????????????????????????????????????????????????
????????, ??????????????Intent??????????????????registerReceiver(BroadcastReceiver, IntentFilter)??????????????????????????????,??????????????????????????????,????????????.
????????(Ordered broadcasts)
??????????????????????????????,??????????intent-filter????priority??????,-1000??
1000????,??????,??????????.??????????????????????????.??????????????????.
????????????
??????????????????intent,Context????????sendBroadcast()??sendOrderedBroadcast()
??????????????????.
????????????????????????????????????????????????????????(??Action??Category)????????Intent?????????????????? Context.sendBroadcast()??sendOrderBroadcast()??sendStickyBroadcast()???????? Intent????????????????????????
????sendBroadcast()??sendStickyBroadcast()????????????Intent????????????????BroadcastReceiver????????????????onReceive()????
????????????????????????
sendBroadcast(intent);
Intent intent = new Intent("cn.lenovo.yangguangf");
sendBroadcast(intent);
??????????????????????????????????http://www.toceansoft.com 4/10
registerreceiver 高级程序员修炼之道-Android培训系列课程之BroadCastReceiver1
??????????????????-Android??????????????BroadCastReceiver
priority????????AndroidManifest.xml??intent-filter????????
<receiver android:name=".MyBroadcastReceiver">
<intent-filter android:priority="1000">
<action android:name="cn.lenovo.yangguangfu"/>
</intent-filter>
</receiver>
sendOrderedBroadcast(intent, receiverPermission);
1??????????????????????????????????-1000??1000????,??????,????????????
2??????????????????????????????????????????????
3????android????????????????????????????????????????sendBroadcast(intent)??????????;
3??????????????????????????
4??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????
sendOrderedBroadcast(intent, receiverPermission);
sendOrderedBroadcast(intent, receiverPermission, resultReceiver,
scheduler, initialCode, initialData, initialExtras)
????????????????????????????????????????????????
receiverPermission????????????????????????????????????????????????null?????????????????? resultReceiver??????BroadcastReceiver????????????????????????
????????????????????????????resultReceiver????;??????null??????????????????????
initialCode????????????????????????????Activity.RESULT_OK??????????-1????????int????????????0,1,2??
initialData????????????????????????????????????,??String????;
initialExtras????????????????????????????????????,??Bundle;
intent The Intent to broadcast; all receivers matching this Intent will receive the broadcast.
??????????????????????????????????http://www.toceansoft.com 5/10
registerreceiver 高级程序员修炼之道-Android培训系列课程之BroadCastReceiver1
??????????????????-Android??????????????BroadCastReceiver
receiverPermission String naming a permissions that a receiver must hold in order to receive your broadcast. If null, no permission is required.
resultReceiver Your own BroadcastReceiver to treat as the final receiver of the broadcast.
scheduler A custom Handler with which to schedule the resultReceiver callback; if null it will be scheduled in the Context's main thread.
initialCode An initial value for the result code. Often Activity.RESULT_OK.
initialData An initial value for the result data. Often null.
initialExtras An initial value for the result extras. Often null.
1?? ????????????????????????????????????-1000??1000????,??????,????????????
2?? ????????????????????????????????????????????????
3?? ????????????????????????????????????????????????????????????????????????????????????????????????abortBroadcast()??
4???????????????????????????????????????????????????????????????????????????????? 5??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????
sendStickyBroadcast(intent);
??????????????Intent????????????????????????????
??????????????????<uses-permission android:name="android.permission.BROADCAST_STICKY"/> ????????????????removeStickyBroadcast(intent);????????????????????????????????
AndroidManifest.xml????????????????????
61阅读提醒您本文地址:
sendStickyOrderedBroadcast(intent, resultReceiver, scheduler,
initialCode, initialData, initialExtras)
??????????????????????????????????????????????
????????????????<uses-permission android:name="android.permission.BROADCAST_STICKY" />????????????????????????????????????????????????????????SecurityException????
??????????????????????????????????http://www.toceansoft.com 6/10
registerreceiver 高级程序员修炼之道-Android培训系列课程之BroadCastReceiver1
??????????????????-Android??????????????BroadCastReceiver
??????????sendStickyOrderedBroadcast????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????
??????????????????
????????????????registerReceiver(BroadcastReceiver receiver, IntentFilter filter)??????????????????????????????BroadcastReceiver????????????????????????????????????????????????????????????????????????
????????????????registerReceiver(receiver, filter, broadcastPermission, scheduler)??????????????
BroadcastReceiver??????????????????????????????????????????????????????????????????????????????????????????????????????????Hander??
????????????????????????????????????????????????????????????????????receiver??????????????????????????????????????????????????????????????????????????????????????????????????????????????????receiver????????????
????????Activity??????????????????????onResume()????????
??????????1????????????????registerReceiver(BroadcastReceiver receiver, IntentFilter filter)??????receiver??filter??????????????????????????????????????????????????????????????
2????????????????????????????????????????????
????????????????????AndroidManifest.xml??????
<receiver android:name=".MyBroadcastReceiver">
<intent-filter android:priority="900">
<action android:name="cn.lenovo.yangguangfu"/>
</intent-filter>
</receiver>
??????????????????????????????????????????????????????
??????????
//??????????????
??????????????????????????????????http://www.toceansoft.com 7/10
registerreceiver 高级程序员修炼之道-Android培训系列课程之BroadCastReceiver1
??????????????????-Android??????????????BroadCastReceiver
/unregisterReceiver(mBatteryInfoReceiver);
??Activity??????????????????????onPuase() ????????
????????????????Activity.onSaveInstanceState(),??????????????????Intent????????
BroadCastReceiver??API??
abortBroadcast():??
??????????????????sendOrderedBroadcast???????????????????????????????????????????????????? clearAbortBroadcast??()??
????????????????????abortBroadcast()??????????????????????????????????????????????????????????????????????
getAbortBroadcast??()??
??????????????????????????????abortBroadcast????????????????abortBroadcast????????????????getAbortBroadcast????????????true; ??????????abortBroadcast()??clearAbortBroadcast ()
getAbortBroadcast????????????false;
public??final??boolean??getDebugUnregister()??
Since: API Level 1
Return the last value given to setDebugUnregister(boolean).
getResultCode??()??
????????????????????????????????????????-1??
// sendBroadcast(intent);
// sendBroadcast(intent, receiverPermission);
// sendOrderedBroadcast(intent, receiverPermission);
// sendStickyBroadcast(intent);
??????????????????????????????????????????????????initialCode?????????????????????? //sendStickyOrderedBroadcast(intent, resultReceiver, scheduler,
??????????????????????????????????http://www.toceansoft.com 8/10
registerreceiver 高级程序员修炼之道-Android培训系列课程之BroadCastReceiver1
??????????????????-Android??????????????BroadCastReceiver
// initialCode, initialData, initialExtras)
// sendOrderedBroadcast(intent, receiverPermission, resultReceiver,
// scheduler, initialCode, initialData, initialExtras)
getResultData??()??
????????????????????initialData????????
getResultExtras(boolean??makeMap)??
If true then a new empty Map will be made for you if the current Map is null; if false you should be
prepared to receive a null Map.
??????
sendStickyOrderedBroadcast(intent, resultReceiver, scheduler,
// initialCode, initialData, initialExtras)??
61阅读提醒您本文地址:
//sendOrderedBroadcast(intent, receiverPermission, resultReceiver,
// scheduler, initialCode, initialData, initialExtras)
??initialExtras????????????
??????????????????????????initialExtras??????????Bundle????????????????????????????????makeMap??????true??false????????????????
isInitialStickyBroadcast??()??
Returns true if the receiver is currently processing the initial value of a sticky broadcast -- that is, the value that was last broadcast and is currently held in the sticky cache, so this is not directly the result of a broadcast right now.
????????????????????????????????????????????????????????true??- ??????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????false??????????????resultReceiver??????????????????????????????false??
isOrderedBroadcast??()??
sendStickyOrderedBroadcast(intent, resultReceiver, scheduler,
??????????????????????????????????http://www.toceansoft.com 9/10
registerreceiver 高级程序员修炼之道-Android培训系列课程之BroadCastReceiver1
??????????????????-Android??????????????BroadCastReceiver
initialCode, initialData, initialExtras)
????????????????????????????true;
????????????????????
onReceive??(Context??context,??Intent??intent)??
public??IBinder??peekService??(Context??myContext,??Intent??service)??
Provide a binder to an already-running service. This method is synchronous and will not start the target service if it is not present, so it is safe to call from onReceive.
Parameters:
myContext The Context that had been passed to onReceive(Context, Intent)
service The Intent indicating the service you wish to use. See Context.startService(Intent) for more
information.
setDebugUnregister??(boolean??debug)??
Control inclusion of debugging help for mismatched calls to {@
Context#registerReceiver(BroadcastReceiver, IntentFilter) Context.registerReceiver()}. If called with true, before given to registerReceiver(), then the callstack of the following Context.unregisterReceiver() call is retained, to be printed if a later incorrect unregister call is made. Note that doing this requires retaining information about the BroadcastReceiver for
??????????????????????????????????http://www.toceansoft.com 10/10
61阅读提醒您本文地址:
本文标题:程序员培训-程序员培训计划61阅读| 精彩专题| 最新文章| 热门文章| 苏ICP备13036349号-1