// 在状态栏提示分享操作 private void showNotification(long cancelTime, String text) { try { Context app = getContext().getApplicationContext(); NotificationManager nm = (NotificationManager) app.getSystemService(Context.NOTIFICATION_SERVICE); final int id = Integer.MAX_VALUE / 13 + 1; nm.cancel(id); long when = System.currentTimeMillis(); Notification notification = new Notification(notifyIcon, text, when); PendingIntent pi = PendingIntent.getActivity(app, 0, new Intent(), 0); notification.setLatestEventInfo(app, notifyTitle, text, pi); notification.flags = Notification.FLAG_AUTO_CANCEL; nm.notify(id, notification); if (cancelTime > 0) { Message msg = new Message(); msg.what = MSG_CANCEL_NOTIFY; msg.obj = nm; msg.arg1 = id; UIHandler.sendMessageDelayed(msg, cancelTime, this); } } catch (Exception e) { e.printStackTrace(); } }
private void showThumb() { String imagePath = (String) reqData.get("imagePath"); Bitmap viewToShare = (Bitmap) reqData.get("viewToShare"); shareImage = false; if (!TextUtils.isEmpty(imagePath) && new File(imagePath).exists()) { try { shareImage = true; image = getBitmap(imagePath); } catch (Throwable t) { System.gc(); try { image = getBitmap(imagePath, 2); } catch (Throwable t1) { t1.printStackTrace(); shareImage = false; } } if (shareImage) { rlThumb.setVisibility(View.VISIBLE); ivPin.setVisibility(View.VISIBLE); ivImage.setImageBitmap(image); } } else if (viewToShare != null && !viewToShare.isRecycled()) { shareImage = true; image = viewToShare; if (shareImage) { rlThumb.setVisibility(View.VISIBLE); ivPin.setVisibility(View.VISIBLE); ivImage.setImageBitmap(image); } } else if (reqData.containsKey("imageUrl")) { new Thread() { public void run() { String imageUrl = String.valueOf(reqData.get("imageUrl")); try { shareImage = true; image = getBitmap(activity, imageUrl); } catch (Throwable t) { t.printStackTrace(); shareImage = false; image = null; } if (shareImage) { UIHandler.sendEmptyMessage( 1, new Callback() { public boolean handleMessage(Message msg) { rlThumb.setVisibility(View.VISIBLE); ivPin.setVisibility(View.VISIBLE); ivImage.setImageBitmap(image); return false; } }); } } }.start(); } }