/**
* 复制单个文件
* @param oldPath String 原文件路径 如:c:/fqf.txt
* @param newPath String 复制后路径 如:f:/fqf.txt
* @return boolean
*/
public void copyFile(String oldPath, String newPath) {
try {
int bytesum = 0;
int byteread = 0;
File oldfile = new File(oldPath);
if (oldfile.exists()) { //文件存在时
InputStream inStream = new FileInputStream(oldPath); //读入原文件
FileOutputStream fs = new FileOutputStream(newPath);
byte[] buffer = new byte[1444];
int length;
while ( (byteread = inStream.read(buffer)) != -1) {
bytesum += byteread; //字节数 文件大小
System.out.println(bytesum);
fs.write(buffer, 0, byteread);
}
inStream.close();
}
}
catch (Exception e) {
System.out.println("复制单个文件操作出错");
e.printStackTrace();
}
}
/**
* 复制整个文件夹内容
* @param oldPath String 原文件路径 如:c:/fqf
* @param newPath String 复制后路径 如:f:/fqf/ff
* @return boolean
*/
public void copyFolder(String oldPath, String newPath) {
try {
(new File(newPath)).mkdirs(); //如果文件夹不存在 则建立新文件夹
File a=new File(oldPath);
String[] file=a.list();
File temp=null;
for (int i = 0; i < file.length; i++) {
if(oldPath.endsWith(File.separator)){
temp=new File(oldPath+file[i]);
}
else{
temp=new File(oldPath+File.separator+file[i]);
}
if(temp.isFile()){
FileInputStream input = new FileInputStream(temp);
FileOutputStream output = new FileOutputStream(newPath + "/" +
(temp.getName()).toString());
byte[] b = new byte[1024 * 5];
int len;
while ( (len = input.read(b)) != -1) {
output.write(b, 0, len);
}
output.flush();
output.close();
input.close();
}
if(temp.isDirectory()){//如果是子文件夹
copyFolder(oldPath+"/"+file[i],newPath+"/"+file[i]);
}
}
}
catch (Exception e) {
System.out.println("复制整个文件夹内容操作出错");
e.printStackTrace();
}
}1. 创建GsmPhone时,mCT = new GsmCallTracker(this);
2. 创建GsmCallTracker时:
cm.registerForCallStateChanged(this, EVENT_CALL_STATE_CHANGE, null); -->
mCallStateRegistrants.add(r);
3. RIL中的RILReceiver线程首先读取从rild中传来的数据:processResponse -> processUnsolicited
4. 对应于incoming call,RIL收到RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED 消息,触发mCallStateRegistrants中的所有记录。
5. GsmCallTracker处理EVENT_CALL_STATE_CHANGE,调用pollCallsWhenSafe
6. 函数pllCallsWhenSafe 处理:
lastRelevantPoll = obtainMessage(EVENT_POLL_CALLS_RESULT);
cm.getCurrentCalls(lastRelevantPoll);
7. RIL::getCurrentCalls
RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_CURRENT_CALLS, result);
...
send(rr);
8. 接着RIL调用processSolicited处理RIL_REQUEST_GET_CURRENT_CALLS的返回结果
9. GsmCallTracker的handleMessage被触发,处理事件EVENT_POLL_CALLS_RESULT,调用函数
handlePollCalls
10. handlPollCalls 调用
phone.notifyNewRingingConnection(newRinging);
11. PhoneApp中创建CallNotifier
12. CallNotifier注册:
registerForNewRingingConnection -> mNewRingingConnectionRegistrants.addUnique(h, what, obj);
Activity的切换动画指的是从一个activity跳转到另外一个activity时的动画。
{它包括两个部分:
一部分是第一个activity退出时的动画;
另外一部分时第二个activity进入时的动画;
在Android的2.0版本之后,有了一个函数来帮我们实现这个动画。这个函数就是YoverridePendingTransition
j这个函数有两个参数,一个参数是第一个activity退出时的动画,另外一个参数则是第二个activity进入时的动画。
这里需要特别说明的是,关于overridePendingTransition这个函数,有两点需要主意
1.它必需紧挨着startActivity()或者finish()函数之后调用"
2.它只在android2.0以及以上版本上适用 下面的附件是我从另外的一个网站上下载过来的一个Demo。
可以帮助大家理解这个东西。
经测试在2.1系统上的手机有效 3.1的平板中这个方法无效
两个Activity跳转的时候,自定义翻页效果:
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
startActivityForResult(intent, 11);
//添加界面切换效果,注意只有Android的2.0(SdkVersion版本号为5)以后的版本才支持
int version = Integer.valueOf(android.os.Build.VERSION.SDK);
if(version >= 5) {
overridePendingTransition(R.anim.zoomin, R.anim.zoomout); //此为自定义的动画效果,下面两个为系统的动画效果
//overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
//overridePendingTransition(android.R.anim.slide_in_left,android.R.anim.slide_out_right);
}
下面为两个自定义的动画效果XML文件,存放位置为:res/anim/
1,动画进入效果:zoomin.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator">
<scale android:fromXScale="2.0" android:toXScale="1.0"
android:fromYScale="2.0" android:toYScale="1.0"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="@android:integer/config_mediumAnimTime" />
</set>
2,动画退出效果:zoomout.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"
android:zAdjustment="top">
<scale android:fromXScale="1.0" android:toXScale=".5"
android:fromYScale="1.0" android:toYScale=".5"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="1.0" android:toAlpha="0"
android:duration="@android:integer/config_mediumAnimTime"/>
</set>