我的應用程序做什麼是很簡單:Android的阻力和ICS中的圖片崩潰(4.0.3)
它顯示上一個GridView 的SD卡和角落的圖標所有圖像的縮略圖這些縮略圖讓用戶可以觸摸它來啓動 拖動圖像的陰影。
該陰影可以放在已經設置了拖動監聽器的視圖上。當 發生時,新的意圖將被調用,圖像文件路徑Uri將作爲 新意圖的額外內容。到現在爲止還挺好。
問題發生在我開始在沒有任何 拖動監聽器的視圖上放下陰影時,最終會凍結屏幕並使移動設備崩潰!
所有我在堆棧跟蹤得到的是這樣的:
03-29 14:24:14.803: I/ViewRootImpl(2496): Reporting drop result: false
03-29 14:24:14.803: W/WindowManager(274): Drag is in progress but there is no drag window handle.
03-29 14:24:15.062: I/ViewRootImpl(2496): Reporting drop result: false
03-29 14:24:15.062: W/WindowManager(274): Drag is in progress but there is no drag window handle.
03-29 14:24:15.294: I/ViewRootImpl(2496): Reporting drop result: false
03-29 14:25:06.972: I/Process(274): Sending signal. PID: 274 SIG: 3
03-29 14:25:06.972: I/dalvikvm(274): threadid=3: reacting to signal 3
03-29 14:25:07.092: I/dalvikvm(274): Wrote stack traces to '/data/anr/traces.txt'
03-29 14:25:10.012: W/ActivityManager(274): Timeout of broadcast BroadcastRecord{2c09ce28 android.intent.action.TIME_TICK} - [email protected]2bf0c4e8, started 10009ms ago
03-29 14:25:10.012: W/ActivityManager(274): Receiver during timeout: BroadcastFilter{2bf0cd08 ReceiverList{2bf0c660 274 system/1000 local:2bf0c4e8}}
03-29 14:25:20.022: W/ActivityManager(274): Timeout of broadcast BroadcastRecord{2c09ce28 android.intent.action.TIME_TICK} - [email protected]2bef04e8, started 10008ms ago
03-29 14:25:20.022: W/ActivityManager(274): Receiver during timeout: BroadcastFilter{2bef0760 ReceiverList{2bef06e8 274 system/1000 local:2bef04e8}}
03-29 14:25:37.092: W/Watchdog(274): WATCHDOG PROBLEM IN SYSTEM SERVER: com.android.server.wm.WindowManagerService
03-29 14:25:37.102: I/Process(274): Sending signal. PID: 274 SIG: 3
03-29 14:25:37.102: I/dalvikvm(274): threadid=3: reacting to signal 3
03-29 14:25:37.182: I/dalvikvm(274): Wrote stack traces to '/data/anr/traces.txt'
03-29 14:25:37.192: I/Process(274): Sending signal. PID: 475 SIG: 3
03-29 14:25:37.192: I/dalvikvm(475): threadid=3: reacting to signal 3
03-29 14:25:37.202: I/dalvikvm(475): Wrote stack traces to '/data/anr/traces.txt'
03-29 14:25:39.204: I/Watchdog_N(274): dumpKernelStacks
03-29 14:25:39.492: I/CrashMonitor(1186): CrashMonitorService: invokeService: android.intent.action.DROPBOX_ENTRY_ADDED
03-29 14:25:39.492: W/Watchdog(274): *** WATCHDOG KILLING THE SYSTEM: com.android.server.wm.WindowManagerService
我的適配器類(其中i執行view.startDrag()方法):
public class ImageCursorAdapter extends CursorAdapter {
private LayoutInflater mInflater;
private final static int mImageColumnID = 0;
private Options mOptions = new Options();;
private Cursor mCursor;
public ImageCursorAdapter(Context context, Cursor c) {
super(context, c);
mInflater = LayoutInflater.from(context);
mOptions.inSampleSize = 4;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
mCursor = cursor;
ViewHolder holder = (ViewHolder) view.getTag();
ImageThumbnailLoader imageLoader = new ImageThumbnailLoader(
holder.thumbImg, cursor.getLong(mImageColumnID),
context.getContentResolver(), false);
imageLoader.execute();
// holder.thumbImg.setImageBitmap(MediaStore.Images.Thumbnails.getThumbnail(
// context.getContentResolver(), cursor.getLong(mColumnID),
// MediaStore.Images.Thumbnails.MICRO_KIND, mOptions));
holder.dragImg.setTag(holder.thumbImg);
holder.dragImg.setId(cursor.getPosition());
holder.dragImg.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
if (action == MotionEvent.ACTION_DOWN) {
mCursor.moveToPosition(v.getId());
int dataColumn = mCursor.getColumnIndex(MediaStore.Images.Media.DATA);
ClipData dragData = ClipData.newPlainText("filename",
mCursor.getString(dataColumn));
DragShadowBuilder shadow = new DragShadowBuilder((View) v.getTag());
return v.startDrag(dragData, shadow, null, 0);
}
return false;
}
});
Log.i("Prototype", "bindView : " + cursor.getPosition());
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
Log.i("Prototype", "newView : " + cursor.getPosition());
View view = mInflater.inflate(R.layout.grid_item, null);
ViewHolder holder = new ViewHolder(view);
view.setTag(holder);
return view;
}
private static class ViewHolder {
ImageView thumbImg, dragImg;
ViewHolder(View base) {
thumbImg = (ImageView) base.findViewById(R.id.thumbImage);
dragImg = (ImageView) base.findViewById(R.id.dragImage);
}
}
}
任何想法/上what`線索在這裏呢?我真的很感激這一點。
在此先感謝。
我已經在我的課上實現了這一點,凍結仍然發生。 它並不總是這種情況發生,只有當我嘗試重複拖動圖標... – ImNotAnUser 2012-05-24 14:34:50
@ImNotAnUser你有沒有想過這個? – DJayC 2013-04-03 09:04:22
@DJayC不,我沒有。最終實現了我自己的拖放框架。 – ImNotAnUser 2013-04-05 16:23:03