Category : kotlin

I would like my application to download an APK file of another app, and then install it (not silently). I tried doing this using the PackageInstaller. I wrote this function: val packageInstaller = MainApplication.context.packageManager.packageInstaller val params = PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL) params.setAppPackageName(MainApplication.context.packageName) val sessionId = packageInstaller.createSession(params) val session = packageInstaller.openSession(sessionId) val out = session.openWrite(MainApplication.context.packageName, 0, -1) val fis ..

Read more

i want to draw a speech bubble using canvas in jetcompose but i dont know how to draw an arrow at bottom end of the Rectangle this is my code: @Composable fun DrawBubble(modifier: Modifier = Modifier) { Box(modifier = modifier) { Canvas(modifier = Modifier.matchParentSize()) { val clipPath = Path().apply { lineTo(size.width, 0f) lineTo(size.width, 30f) lineTo(size.width, ..

Read more

private fun retrieveUid() { val docIdTxt = StringBuffer() //val docIdTxt = StringBuffer() db.collection("studentSRN").get() .addOnCompleteListener { if(it.isSuccessful) { for(document in it.result!!) { if(document.id == auth.currentUser?.uid){ docIdTxt.append(document.data.getValue("SRN").toString()) break } } } } Toast.makeText(this,"$docIdTxt",Toast.LENGTH_SHORT).show() } The problem i am having is that when i TOAST iniside the if block, the value of docIdTxt is shown but when i ..

Read more

I have a button that the user can click to hide a fragment, but the fragment also needs to be hidden if clicked outside of the box. Right now I tried this: fun onTouchOutSide(activity: Activity, event: MotionEvent?) { val r1 = Rect(0, 0, 0, 0) this.layoutID?.let { activity.findViewById<FragmentContainerView>(it).getHitRect(r1) } val intersectsContainer: Boolean = event?.getX()?.toInt()?.let { ..

Read more

I’m getting from Room’s query Flow<List<ByteArray>>, which need to be converted to InputStream class FlowListInputStream( private val scope: CoroutineScope, private val flow: Flow<List<ByteArray>> //size of list could be up-to several thousands ): InputStream() { override fun read(): Int { //todo… } } Context: In my SQLite I’m storing in BLOBs number of video/audio/image binaries with ..

Read more

Notifications are showing in the background but when the app is in the foreground notifications are not showing. I applied many solutions but they do not work for me. Can anyone tell me where is my mistake? thanks in advance Here is Manifest <service android:exported="false" android:name=".services.MyFirebaseMessagingService"> <intent-filter> <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> </intent-filter> </service> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/cute" /> ..

Read more

How do I get name of a drawable that was already set to an imageview? I need to get the part that is after R.drawable.________ I’ve found that from Resources I can get resourceName, but it’s just name of the imageview, not the drawable. Thanks! Source: Android..

Read more