主要知识点:
1. 在非Activity程序中(如service 或者 BroadcastReceiver等)调用StartActivity(),即从外部调用Activity;
Activity 继承了context,并重载了startActivity()方法;不能像内部调用一样,直接使用startActivity,为了保护Activity 堆栈,此时需要开启一个新的task,加一个flag,
添加: intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 即可;
2. 线程的使用;
创建线程:
public class MyRateThread implements Runnable {
public MyRateThread() {}
public void run() {
mHandler.post(new Runnable(){ //add a new task to the pthread ;
public void run(){
}
});
}
调用线程:
Thread pthread = new Thread(new MyRateThread());
pthread.start();
3. 利用Sharedpreference 读取和存放数据;
获取Sharedpreference 对象;
getSharedPreferences( , );
读取数据:
getSharedPreferences( , ).getValue();
改写数据:
获取edit对象:getSharedPreferences( , ).edit();
更改数据: getSharedPreferences( , ).edit().putvalue();
提交: editor.commit();
The defferences between getDefaultSharedPreference() &