问题一
startActivity方法启动一个新的activity时怎么让新的activity在另一个新的
task中
<activity android:name=".Notes.EditWidget"
android:taskAffinity="android.task.Notes.EditWidget"/>
或:intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
即可当启动一个新的activity,返回时,不会返回到此任务home键退出的事件的activity中去。
问题二
camera源码bug:
照相机--切换到摄像机--Home退出;
点击桌面照相机程序---->进入摄像机启动界面
处理方法:
switchToVideoMode()->gotoVideoMode(...)->startCameraActivity(...)中添加属性:
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
备注:
照相机处android:launchMode="singleTask"也可解决此问题,但却会导致信息无法添加照相机附件
问题四
添加view
问题五:
将view转换为bitmap
view.clearFocus();
view.setPressed(false);
boolean willNotCache = view.willNotCacheDrawing();
view.setWillNotCacheDrawing(false);
// Reset the drawing cache background color to fully transparent
// for the duration of this operation
int color = view.getDrawingCacheBackgroundColor();
view.setDrawingCacheBackgroundColor(0);
if (color != 0) {
view.destroyDrawingCache();
}
view.buildDrawingCache();
Bitmap cacheBitmap = view.getDrawingCache();
if (cacheBitmap == null) {
Log.e("", "failed getViewBitmap(" + view + ")", new RuntimeException());
return null;
}
Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
// Restore the view
view.destroyDrawingCache();
view.setWillNotCacheDrawing(willNotCache);
view.setDrawingCacheBackgroundColor(color);
return bitmap;
}
使用:
BitmapDrawable bmp=new BitmapDrawable(getViewBitmap(siwtcherView));
ImageView imageView=new ImageView(this);
imageView.setImageDrawable(bmp);