Здравствуйте! Подскажите пожалуйста! При нажатии на Share Image, не появляются окна с кнопками приложений для того, чтобы поделиться, вместо этого выкидывает с появлением белого окна и перебрасывает на меню выше.
Код | shareImgBtn.setOnClickListener { val myDrawable = Image2_share.drawable val bitmap = (myDrawable as BitmapDrawable).bitmap val file = File(externalCacheDir, "image2.png") val fOut = FileOutputStream(file) bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut) fOut.flush() fOut.close() file.setReadable(true, false) val intent = Intent(Intent.ACTION_SEND) intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK; intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)) intent.type = "image/png" intent.putExtra(Intent.EXTRA_SUBJECT, "Subject here") startActivity(Intent.createChooser(intent, "Share Image via")) }
|
Код | <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".category.imageshare_ctg" android:background="@drawable/fon"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical"> <LinearLayout android:layout_margin="20dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="left"> <Button android:id="@+id/exit" android:layout_width="75dp" android:layout_height="75dp" android:layout_marginRight="10dp" android:background="@drawable/exit" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="center" android:gravity="center"> <TextView android:layout_gravity="center" android:layout_width="270dp" android:layout_height="match_parent" android:gravity="center" android:background="#00FFFFFF" android:text="НАЗАД" android:textColor="#000" android:textSize="23sp" android:textStyle="bold|italic" /> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="center"> <ImageView android:id="@+id/Image2_share" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/image2" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="center"> <Button android:id="@+id/shareImgBtn" android:text="Share Image" android:layout_width="300sp" android:layout_height="100sp" /> </LinearLayout> </LinearLayout> </ScrollView> </RelativeLayout>
|
|