Я пытаюсь создать изображение из вида, сохранить его, а затем поделиться им.Я использую Fileprovider, но все еще получаю известную ошибку:
E / JavaBinder: !!!СБОЙ СДЕЛКИ БИНДЕРА !!!(размер пакета = 728232) D / AndroidRuntime: завершение работы VM E / AndroidRuntime: ИСКЛЮЧИТЕЛЬНОЕ ИСКЛЮЧЕНИЕ: основной Процесс: com.blagues.agogo, PID: 18150 java.lang.RuntimeException: android.os.TransactionTooLargeException: размер пакета данных 728232 байт
это мой код:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_shareable_img, container, false);
((MainActivity) getActivity()).getSupportActionBar().setTitle(R.string.preview);
li = (RelativeLayout) view.findViewById(R.id.li);
li.getLayoutParams().width = 720;
li.getLayoutParams().height = 980;
li.requestLayout();
quote = getArguments().getString("quote");
qText = (TextView) view.findViewById(R.id.qText);
extra = (TextView) view.findViewById(R.id.extra);
Typeface fontQuote = Typeface.createFromAsset(getActivity().getAssets(),
"fonts/Roboto-Regular.ttf");
qText.setTypeface(fontQuote);
qText.setTextSize(12);
qText.setText(quote);
setBackground(li);
fab = (FloatingActionButton) view.findViewById(R.id.floatingActionButton);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
doShare();
}
});
return view;
}
public void doShare() {
Bitmap bitmap = getBitmapFromView(li);
try {
File file = new File(Environment.getExternalStorageDirectory(),"bgpic1.jpeg");
FileOutputStream fOut = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
fOut.flush();
fOut.close();
file.setReadable(true, true);
final Intent intent = new Intent(Intent.ACTION_SEND);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
intent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(getActivity(), BuildConfig.APPLICATION_ID , file));
}else{
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
}
intent.putExtra(Intent.EXTRA_TEXT,getString(R.string.share_via));
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("image/*");
Intent chooser = Intent.createChooser(intent,"Partager..");
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
public void setBackground(View view) {
view.setBackgroundResource(R.drawable.bg3);
}
private Bitmap getBitmapFromView(View view) {
Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(returnedBitmap);
Drawable bgDrawable = view.getBackground();
if (bgDrawable != null) {
bgDrawable.draw(canvas);
} else {
canvas.drawColor(Color.WHITE);
}
view.draw(canvas);
return returnedBitmap;
}
Ты хоть представляешь, что я пропустил?
Спасибо