Android 在安卓系统中,从相机拍摄照片并在通知图标中设置该图像
我想将我的相机图片设置为通知图标 这是我的主要活动Android 在安卓系统中,从相机拍摄照片并在通知图标中设置该图像,android,notifications,icons,Android,Notifications,Icons,我想将我的相机图片设置为通知图标 这是我的主要活动 intent=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, 0); protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, re
intent=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode==RESULT_OK){
extras=data.getExtras();
bmp=(Bitmap) extras.get("data");
imageView.setImageBitmap(bmp);
}
}
从我的广播接收器,我试图得到位图作为
public void onReceive(Context context, Intent intent) {
///////////////////////////................
Bitmap bitmap = (Bitmap) intent.getParcelableExtra("image");
Notification notification2=new Notification.Builder(context).setTicker(from)
.setContentTitle(from)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(bitmap)
.setContentText(message).setContentIntent(contentIntent)
.addAction(0,"remind",contentIntent).build();
但这不起作用,我得到了强制停止:如果你得到了错误
E/JavaBinder﹕ !!! FAILED BINDER TRANSACTION !!!
这是因为位图对于Android活页夹来说太大了,我相信它有1MB的限制。您应该先查看压缩图像,然后再尝试将其打包传递。看看这篇文章:我也尝试过位图Bitmap=Bitmap intent.getParcelableExtraimage;Resources res=context.getResources;int height=int res.getdimenandroid.R.dimen.notification\u large\u icon\u height;int width=int res.getdimenandroid.R.dimen.notification\u large\u icon\u width;bitmap=bitmap.createScaledBitmapbitmap,宽度,高度,false;////。setSmallIconR.drawable.ic_启动器setLargeIconbitmap//。。。。。。。。。。但是仍然会出错如果您可以提供一些错误消息的输出,那么帮助您会容易得多。就像logcat输出一样。