1.启动程序无需动画
- myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);//1.5的应该使用,这样就可以没有动画效果了??
- getWindow().setWindowAnimations(0)//1.6的应该使用,这不要忘记放在activity??
myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);//1.5的应该使用,这样就可以没有动画效果了getWindow().setWindowAnimations(0)//1.6的应该使用,这不要忘记放在activity
?
2.SD卡创建目录
- File?wallpaperDirectory?=?new?File("/sdcard/Wallpaper/");??
- wallpaperDirectory.mkdirs();??
- File?outputFile?=?new?File(wallpaperDirectory,?filename);??
- FileOutputStream?fos?=?new?FileOutputStream(outputFile);???
File wallpaperDirectory = new File("/sdcard/Wallpaper/");wallpaperDirectory.mkdirs();File outputFile = new File(wallpaperDirectory, filename);FileOutputStream fos = new FileOutputStream(outputFile);
?注意要添加权限哦
- <uses-permission?android:name="android.permission.WRITE_EXTERNAL_STORAGE"?/>??
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
?
3.文字中间加横线效果
- priceTV.setText("价格:2.00元");?????
- priceTV.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);????
priceTV.setText("价格:2.00元"); priceTV.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
?
4.android中使用事务操作SQLite数据库
- SQLiteDatabase?db?=?....;???
- db.beginTransaction();//开始事务???
- try?{???
- ????db.execSQL("insert?into?person(name,?age)?values(?,?)",?new?Object[]{"张三",???
- ??
- 4});??
- ????db.execSQL("update?person?set?name=??where?personid=?",?new?Object[]{"李四",?1});??
- ????db.setTransactionSuccessful();//调用此方法会在执行到endTransaction()时提交当前事??
- ??
- 务,如果不调用此方法会回滚事务???
- }?finally?{???
- ????db.endTransaction();//由事务的标志决定是提交事务,还是回滚事务???
- }??
- db.close();??
SQLiteDatabase db = ....; db.beginTransaction();//开始事务 try { db.execSQL("insert into person(name, age) values(?,?)", new Object[]{"张三", 4}); db.execSQL("update person set name=? where personid=?", new Object[]{"李四", 1}); db.setTransactionSuccessful();//调用此方法会在执行到endTransaction()时提交当前事务,如果不调用此方法会回滚事务 } finally { db.endTransaction();//由事务的标志决定是提交事务,还是回滚事务 }db.close();?
5. 关于短信类SmsMessage的疑问
- public?void?onReceive(Context?context,?Intent?intent)?{??
- ??//?TODO?Auto-generated?method?stub??
- ??Log.d(TAG,?"--->onReceive??,SMS?reach");??
- ????
- ??Bundle?bundle?=?intent.getExtras();??
- ????????if?(bundle?!=?null)?{??
- ????????????Object[]?pdus?=?(Object[])?bundle.get("pdus");??
- ????????????SmsMessage[]?messages?=?new?SmsMessage[pdus.length];??
- ????????????for?(int?i?=?0;?i?<?pdus.length;?i++)?{??
- ????????????????messages?=?SmsMessage.createFromPdu((byte[])?pdus);??
- ????????????}??
- ???????????for?(SmsMessage?smsMessage?:?messages)?{??
- ????????????????from?=?smsMessage.getDisplayOriginatingAddress();??
- ????????????????data?=?smsMessage.getDisplayMessageBody().trim();??
- ????????????????Log.d(TAG,?from?+?"?"?+?data);??
- ?????????????????//处理内容??
- ?????????????????response(context,?data);??
- ?????????????????}??
- ????????}??
- }?