第一篇:Android的getSystemService函数学习总结
函数getSystemService。
public Object getSystemService(String name)
Parameters
nameThe name of the desired service.ReturnsThe service or null if the name does not exist.Open Declaration Object android.app.Activity.getSystemService(String name)
Return the handle to a system-level service by name.The class of the returned object varies by the requested name.Currently available names are:
Note: System services obtained via this API may be closely associated with the Context in which they are obtained from.In general, do not share the service objects between various different contexts(Activities, Applications, Services, Providers, etc.)
译文:通过这个接口获取到的System services(系统服务)会和他们相应的Context(上下文)有紧密联系。通常,不要在不同的上下文中(Activities, Applications, Services, Providers,etc.)共享同一个System services对象。
---------》WINDOW_SERVICE(“window”)
The top-level window manager in which you can place custom windows.The returned object is a WindowManager.使用方法,例如:
DisplayMetrics metrics = new DisplayMetrics();
WindowManager wm =(WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE);
Display d = wm.getDefaultDisplay();
d.getMetrics(metrics);
addResult(SCREEN_WIDTH, metrics.widthPixels);
addResult(SCREEN_HEIGHT, metrics.heightPixels);
addResult(SCREEN_DENSITY, metrics.density);
addResult(SCREEN_X_DENSITY, metrics.xdpi);
addResult(SCREEN_Y_DENSITY, metrics.ydpi);
注意addResult是自定义函数。
其中DisplayMetrics还可以这样使用,DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
重点需要关注WindowManager的getDefaultDisplay用法。
---------》LAYOUT_INFLATER_SERVICE(“layout_inflater”)
A LayoutInflater for inflating layout resources in this context.例如:
final LayoutInflater mInflater;
mInflater =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
public View getView(int position, View convertView, ViewGroup parent){
View view;
if(convertView == null){
view = mInflater.inflate(android.R.layout.simple_list_item_1, parent, false);
} else {
view = convertView;
}
bindView(view, mList.get(position));
return view;
}
注意其中的inflate方法。
---------》ACTIVITY_SERVICE(“activity”)
A ActivityManager for interacting with the global activity state of the system.使用方法,例如:
public AppListAdapter(Context context){
mContext = context;
ActivityManager am =(ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List
for(ActivityManager.RunningAppProcessInfo app : appList){
if(mList == null){
mList = new ArrayList
}
mList.add(new ListItem(app));
}
if(mList!= null){
Collections.sort(mList, sDisplayNameComparator);
}
}
注意getRunningAppProcesses()方法。
---------》POWER_SERVICE(“power”)
A PowerManager for controlling power management.例如:
PowerManager pm =(PowerManager)context.getSystemService(Context.POWER_SERVICE);
pm.goToSleep(SystemClock.uptimeMillis());
注意goToSleep()方法。
再如:
private WakeLock mWakeLock = null;
mWakeLock = mPm.newWakeLock(PowerManager.FULL_WAKE_LOCK, “ConnectivityTest”);
mWakeLock.acquire();
(mWakeLock.release();)
---------》ALARM_SERVICE(“alarm”)
A AlarmManager for receiving intents at the time of your choosing.例如:
设置闹钟
private void scheduleAlarm(long delayMs, String eventType){
AlarmManager am =(AlarmManager)getSystemService(Context.ALARM_SERVICE);
i.putExtra(TEST_ALARM_EXTRA, eventType);
i.putExtra(TEST_ALARM_ON_EXTRA, Long.toString(mSCOnDuration));
i.putExtra(TEST_ALARM_OFF_EXTRA, Long.toString(mSCOffDuration));
i.putExtra(TEST_ALARM_CYCLE_EXTRA, Integer.toString(mSCCycleCount));
PendingIntent p = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime()+ delayMs, p);}
---------》NOTIFICATION_SERVICE(“notification”)
A NotificationManager for informing the user of background events.用于显示通知栏,例如如下经典函数:
protected void showNotification(){
// look up the notification manager service
//创建NotificationManager
NotificationManager nm =(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
// The details of our fake message
//显示的信息,title和content
CharSequence from = “Joe”;
CharSequence message = “kthx.meet u for dinner.cul8r”;
// The PendingIntent to launch our activity if the user selects this notification
//点击事件的相应窗口
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,new Intent(this, IncomingMessageView.class), 0);
// The ticker text, this uses a formatted string so our message could be localized
String tickerText = getString(R.string.imcoming_message_ticker_text, message);
// construct the Notification object.Notification notif = new Notification(R.drawable.stat_sample, tickerText,System.currentTimeMillis());
// Set the info for the views that show in the notification panel.notif.setLatestEventInfo(this, from, message, contentIntent);
// after a 100ms delay, vibrate for 250ms, pause for 100 ms and
// then vibrate for 500ms.notif.vibrate = new long[] { 100, 250, 100, 500};
// Note that we use R.layout.incoming_message_panel as the ID for
// the notification.It could be any integer you want, but we use
// the convention of using a resource id for a string related to
// application.nm.notify(R.string.imcoming_message_ticker_text, notif);
}
---------》KEYGUARD_SERVICE(“keyguard”)
A KeyguardManager for controlling keyguard.键盘锁,例如:
KeyguardManager keyguardManager =
(KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE);
if(keyguardManager.inKeyguardRestrictedInputMode()){
return false;
}
---------》LOCATION_SERVICE(“location”)
A LocationManager for controlling location(e.g., GPS)updates.得到位置信息,例如:
LocationManager locationManager =(LocationManager)mContext.getSystemService(Context.LOCATION_SERVICE);Location location = null;
List
for(int i = 0;i < providers.size();++i){
String provider = providers.get(i);
location =(provider!= null)? locationManager.getLastKnownLocation(provider): null;
if(location!= null)
break;
}
---------》SEARCH_SERVICE(“search”)
A SearchManager for handling search.创建搜索服务,例如:
SearchManager searchManager =
(SearchManager)context.getSystemService(Context.SEARCH_SERVICE);
ComponentName name = searchManager.getWebSearchActivity();
if(name == null)return null;
SearchableInfo searchable = searchManager.getSearchableInfo(name);
if(searchable == null)return null;
---------》VIBRATOR_SERVICE(“vibrator”)
A Vibrator for interacting with the vibrator hardware.提供震动服务,例如:
private static final SparseArray
static {
sVibrationPatterns.put(AccessibilityEvent.TYPE_VIEW_CLICKED, new long[] {
0L, 100L
sVibrationPatterns.put(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED, new long[] {
0L, 100L
});
sVibrationPatterns.put(AccessibilityEvent.TYPE_VIEW_SELECTED, new long[] {
0L, 15L, 10L, 15L
});
sVibrationPatterns.put(AccessibilityEvent.TYPE_VIEW_FOCUSED, new long[] {
0L, 15L, 10L, 15L
});
sVibrationPatterns.put(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, new long[] {0L, 25L, 50L, 25L, 50L, 25L
});
sVibrationPatterns.put(INDEX_SCREEN_ON, new long[] {
0L, 10L, 10L, 20L, 20L, 30L
});
sVibrationPatterns.put(INDEX_SCREEN_OFF, new long[] {
0L, 30L, 20L, 20L, 10L, 10L
});
}
private Vibrator mVibrator;
mVibrator =(Vibrator)getSystemService(Service.VIBRATOR_SERVICE);
Handler mHandler = new Handler(){
@Override
public void handleMessage(Message message){
switch(message.what){
case MESSAGE_VIBRATE:
int key = message.arg1;
long[] pattern = sVibrationPatterns.get(key);
mVibrator.vibrate(pattern,-1);
return;
case MESSAGE_STOP_VIBRATE:
mVibrator.cancel();
return;
}
}
};
---------》CONNECTIVITY_SERVICE(“connection”)
A ConnectivityManager for handling management of network connections.得到网络连接的信息,例如:
private boolean isNetworkConnected(){
NetworkInfo networkInfo = getActiveNetworkInfo();
return networkInfo!= null && networkInfo.isConnected();
}
private NetworkInfo getActiveNetworkInfo(){
ConnectivityManager connectivity =
(ConnectivityManager)getContext().getSystemService(Context.CONNECTIVITY_SERVICE);if(connectivity == null){
return null;
}
return connectivity.getActiveNetworkInfo();
}
---------》WIFI_SERVICE(“wifi”)
A WifiManager for management of Wi-Fi connectivity.例如:
进行wifi的打开,关闭,状态判断等。
private WifiManager mWm;
mWm =(WifiManager)getSystemService(Context.WIFI_SERVICE);
创建两个View单击事件的监听器,监听器实现onClick()方法:
private View.OnClickListener mEnableWifiClicked = new View.OnClickListener(){
public void onClick(View v){
mWm.setWifiEnabled(true);
}
};
private View.OnClickListener mDisableWifiClicked = new View.OnClickListener(){
public void onClick(View v){
mWm.setWifiEnabled(false);
}
};
---------》INPUT_METHOD_SERVICE(“input_method”)
An InputMethodManager for management of input methods.得到键盘或设置键盘相关信息,例如:
private void hideSoftKeyboard(){
// Hide soft keyboard, if visible
InputMethodManager inputMethodManager =(InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(mList.getWindowToken(), 0);
}
---------》UI_MODE_SERVICE(“uimode”)
An UiModeManager for controlling UI modes.UI信息相关,例如:
int mUiMode = Configuration.UI_MODE_TYPE_NORMAL;
try {
IUiModeManager uiModeService = IUiModeManager.Stub.asInterface(ServiceManager.getService(Context.UI_MODE_SERVICE));
mUiMode = uiModeService.getCurrentModeType();
} catch(RemoteException e){
---------》DOWNLOAD_SERVICE(“download”)
A DownloadManager for requesting HTTP downloads
下载相关的接口,例如:
private void downloadUpdate(Context context, String downloadUrl, String fileName){
LogUtil.i(TAG, “downloadUpdate downloadUrl = ” + downloadUrl);
Uri downloadUri = Uri.parse(downloadUrl);
DownloadManager dm =(DownloadManager)context.getSystemService(Context.DOWNLOAD_SERVICE);Request downloadRequest = new Request(downloadUri);
//downloadRequest.setDescription(context.getText(R.string.upd_auto_check_prompt));
downloadRequest.setVisibleInDownloadsUi(true);//TODO:change to false when release!
//downloadRequest.setAllowedNetworkTypes(Request.NETWORK_WIFI);
downloadRequest.setDestinationInExternalPublicDir(“DoctorAn”, fileName);
downloadRequest.setTitle(context.getString(R.string.upd_downloading));
long downloadId = dm.enqueue(downloadRequest);
Map
temp.put(“fileName”, fileName);
((MPApplication)context.getApplicationContext()).getDownloadMap().put(downloadId, temp);}
第二篇:简单函数归纳总结
随机取值:
1、randbetween(最小整数,最大整数)
2、rand()0~1 编辑组合,如:30~40,可编辑为:rand()*30+103、pi()3.14159........筛选值:
1、min(数值.....)取最小值
2、median(数值.....)取中值
3、max(数值.....)取最大值
4、small(数组,k)第k个最小值
5、Large(数组,k)第k个最大值
6、mode(数值)返回在区域中出现频率最多的数
7、Mod(数值,除数)返回余数
求值:
1、求和 sum(数值1,........)
sumif(区域,条件,求和区域)
sumifs(求和区域,区域1,条件1,.......)
2、相乘 product(数值1,........)
3、平方和 sumsq(数值1,........)
4、平方根 sqrt(数值)
5、方差 var(数值1,........)
6、标准差 stdev(数值)
7、角度换算为弧度 randians(角度)
8、弧度换算为角度 degrees(弧度)
9、求平均值 average(数值)
10、求平均值 average(数值,区域1,条件1,........)
11、绝对值 abs(数值)
返回值:
1、trunc(数值,小数位数)将小数部分截去,返回整数
2、Round(数值,小数位数)按指定位数取整,遵循四舍五入
Roundup(数值,小数位数)向上按指定位数取整,不遵循四舍五入Rounddown(数值,小数位数)向下按指定位数取整,不遵循四舍五入
3、odd(数值)对指定数值沿绝对值增大方向取整后最接近的奇数
4、even(数值)对指定数值沿绝对值增大方向取整后最接近的偶数 排序:
1、rank(数值,引用,排位方式)“引用”使用“绝对引用”
第三篇:函数总结
常用函数
sum(数值1,数值2……)求和
average(数值1,数值2……)求平均值
max(数值1,数值2……)求最大值
min(数值1,数值2……)求最小值
count(数值1,数值2……)计数
注意:count只能统计数字的个数,对文本无效
rank(数值,数值所在列,0)排名次
注意:数值所在列要用F4键,锁定
countif(统计的范围,统计条件)有条件统计个数
round(数值,保留的小数位数)四舍五入
if(条件表达式,条件成立时返回的值,条件不成立时返回的值)注意:在office 2010中IF最多能够嵌套64层
sumif(条件所在范围,条件表达式,求和的区域)有条件求和 or(,,,……)逻辑判断(只要有一个为真,结果就是真)and(,,,……)逻辑判断(全部为真时,结果才是真的)lookup(查找内容,查找内容所在区域,返回的区域)查找 注意:要使用lookup函数必须先对查找内容进行升序排序 vlookup(查找的内容,表格所在区域,返回第几列的信息,0)查找与首行相匹配的内容,返回指定列的信息
iserror()错误检查
mid(文本字符串,从第几位提取,提取几位)从字符串中提取信
息
mod(被除数,除数)取余
concatenate(字符串1,字符串2,……)将255个字符串连接在一起
today()返回当前的系统时间(无参数)
year(日期)提取日期中的年份
fv(利率,存款时间,每期存款金额,账户现有金额,期初或期末存钱)零存整取
pmt(利率,还贷时间,贷款金额,最后一次还款金额,期初期末)分期付款
第四篇:初中生如何学习函数
初中生如何学习函数
【摘要】初中生活的学习是一个人步入成功之路的过程中很关键的一步,在初中所学知识的所有章节中,函数知识是最为抽象,最难理解的内容,中学生在学习这些内容是不但要有刻苦的钻研精神,还要有正确的思考和学习方法,在理接课题内容的基础上大胆的猜想,大量的练习时必不可少的。
【关键词】数学学习函数开放式学习课题研究
初中数学是整个学习时段中最基础、最根本的一个学段,初中数学知识繁杂,知识面广,它贯穿整个学段的全部,在初中数学的教育学的过程中,学生最为头疼的问题就是函函数的学习,许多的学生学习函数是都感觉力不从行,那么如何学习函数呢,我的认识有如下几点。
一、正确理解函数的概念,会利用解析式和图像两种方法理解函数。
学生在学习函数的时候一定要牢牢把握函数的概念,所谓函数就是两个变量之间的关系,当一个量发生变化时另一个量也随之发生变化,一个量的变化引起了领一个量的变化。学生可以理解为“先变化的量叫做自变量,后变化的量叫做因变量”学生在理解时可以用“树和影子”的关系来理解函数中两个变量之间的关系。即树的运动,引起了影子的运动。“树”相当于自变量“影子”相当于因变量。通过简单的生活实例,学生可以更好的理解函数的概念及变量之间的关系。函数中给自变量一个值,因变量只有唯一的值与其对应,学生理解时,可以在自变量的取值范围内取一个值来看因变量的值,对于给定的图像我们可以再横轴上取一点做横轴的垂线,看垂线和图像的交点的个数来判断。
二、正确理解函数的性质,会利用函数的性质解决一些实际问题。
函数的性质是学生学习函数的重要工具,学生只有在正确理解函数性质的基础上再能才能解决函数的综合性题目。所以说正确理解函数的性质是学习初中函数的关键,函数的三、正确理解函数中的数形结合,函数值与自变量的关系。
四、会利用函数的知识解方程(组)、不等式(组)。
五、会利用函数知识解决生活中的实际问题。
如运费,交水费,电费等等。
六、正确理解函数
第五篇:EXCEL函数总结
一、数据录入
1.”北京达内”@+文本
2.”0020”#+数字
3.数据有效性
4.工作表加密只读不能改 审阅-----保护工作表
-----部分保护-----允许用户编制区域
5.加密文件:文件---信息---保护工作部
6.排序:数据----排序----选中行----升序、降序
7.筛选数据------筛选-------按颜色筛选、按数字筛选
8.冻结视图----冻结窗口----首行、首列、冻结拆分窗格 冻结时选中下一行或者下一列再冻结
比如冻结第五行和第三列,选中第六行和第四列交叉单元格,选中冻结窗口-----冻结拆分窗格
9.开始---条件格式------新建规则、管理规则(已设定好的)建好规则后,进入管理规则,选中区域
条件格式---突出显示单元格规则-----大于、等于、重复值
使用公式确定要设置格式的单元格,开始去掉锁定符合($)
10.插入图表(曲线图用于趋势、柱状图用于比较、饼状图用于百分比)选定作表+按住CTRL(先选定,再按CTRL)----往后拉
12.复制工作表到其他工作薄 区域---插入图表---点右键加入数据
选定横轴的汉字---点右键---设定坐标轴格式---对齐方式-----文字方向
11.移动复制工作表 复制:选定工
选中工作表----点右键----选择移动或者复制------选中要进入的工作薄
二、日期函数
1.date日期公式录入=date(year, month,date)比如:AI
BI
c1
2.day哪天公式=day(D2)=26号 比如D2单元格日期是2012-02-26 3.month哪月公式=month(D2)=2月 比如D2单元日期是2012-02-26 4.哪年公式同上
5.datedif 判断两个日期间的天数或者年月数 公式=datedif(起始日期,终结日期,参数)参数可以是年、月、日
------“y”,”m”,”d”
满三十天算一个月,满365天算一年,日期掐头不算尾
三、统计函数
1.SUM 跨表求和=SUM(表1:表12 单元格)
点击表1,按住SHIFT键,再选择表12,再选中要相加的单元格,单元格与前面没有逗号
2.SUMIF(条件区域,条件,求和区域)
3.SUMIFS(求和区域,条件1的区域,条件1,条件2的区域,条件2,…….条件N)
4.sumproduct=((条件1=条件1区域)*(条件2=条件2区域)*(条件3=条件3区域)*……….*(求和区域))
有求和区域是求和,无求和区域是计数(不能包括标题行)
5.round函数,四舍五入求数 比如:公式=round(D2,2),求D2单元格两位小数,四舍五入
6.数据透视表插入----数据透视表
1).选中表中区域---插入----数据透视表---选中需要的区域(行、列、数量………)
2).数据透视图
选中表中区域----插入----数据透视图
四、判断函数
1.IF(判断的条件,满足条件时返回的值,不满足条件时返回的值)1)如:公式=IF(D2>=60,”及格”,”不及格”)假如D2>=60,则显示及格,否则显示不及格
2)比如:公式=IF(条件1,返回值1,IF(条件2,返回值2,IF(条件3,返回值3,返回值4)))
3)公式=IF(C4<60,”不及格”,IF(C4<70,”及格”,IF(C4<80,”良好”,”优秀”)))
假如C4小于60,不及格,等于大于60小于70,及格,等于大于70小于80,良好,否则(大于等于80)优秀。2.and函数
公式=and(条件1,条件2,……)
同时满足条件,返回true,否则返回false 比如:公式=and(C3=”男”,D3>3000)
表示如果C3是男,D3大于3000,返回值true否则false 公式=IF(and(C3=”男”,D3>3000),”考虑”,”不考虑”)表示如果C3是男,D3大于3000,就考虑,否则不考虑 3.or函数
公式=or(条件1,条件2,……)满足其中一个条件返回true 4.逻辑函数
公式=VLOOKUP(查找条件,条件区域,区域内所求值所在的列,0/1)0表示精确查找,1表示模糊查找
公式=VLOOKUP(A2,B2:F15,3,0)
表示在B2:15中与A2内容相同的单元格,在所选区域内第三列的值 5.文本函数
1)合并函数字符串 公式=A1&B2 比如:A1=达内,B2=500 则公式=A1&B2,则显示达内500 2)mid函数与left,right函数大致相同
比如:公式=mid(要去用的字符串所在的单元格,从第一位开始,取到第几位)
假如D2=fghsds265, 公式=mid(D2,5,3),则公式等于ds2 6.函数LEN,取所取字符串的位数
比如:A1=300786,则公式=LEN(A1)的值为6 如果A3等于达内科技,则公式=LEN(A3)的值为4
7.Countif条件计数 公式=countif(区域,条件)
比如:公式=countif(A1:F10,50),表示在A1到F10的单元格内数 值为50的单元格的个数。