• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

READ_MEDIA_AUDIO

I adapted to the new permissions and wanted to check if the READ_MEDIA_AUDIO was set by calling
if(ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.READ_MEDIA_AUDIO
!= PackageManager.PERMISSION_GRANTED)
But the new permissions are not in the list of android.Manifest.permission so this won't compile.
I've googled for the answer for a couple of hours now... Anybody knows how to handle this?
/Anton

Android 4.4.2(Kitkat): Screen Lock and Reaching Files Through USB

Hello.

I have an Android 4.4.2(Kitkat) mobile phone which needs to be repaired.(It doesn't charge)

I have some important files in it. I don't want the people who repairs it to reach my files.

Before my phone had this problem, it had a password which worked as a screen lock. I had to enter it each time I unlocked the screen.

If they fix the phone and, lets say connect it to their PC via USB, will they be able to reach the files or will my screen lock is going to prevent them from reaching my files? I don't remember
1) if it asked for permission when connected to USB, to show the files. (it probably does)
2) if I had to enter my password in such situation to give permission.

I'd like to learn if its going to ask my password before that permission message pops up, after being connected to a USB. So they won't be able to see my files as they don't know the password.

Thanks in advance.

AlarmManager not working for 5 minutes periodic update

In my application I was using the setRepeating method of the AlarmManager class to perform the data update every 5 minutes. But in newer versions this logic started to have problems triggering the alarm. Searching, I saw that this method is not accurate, due to the concern of optimizing the battery on the part of the OS. I saw that there are methods like setExact and setExactAndWhileIdle, they are not as exact as the name suggests, because they admit a certain delay, mainly when the device is inactive. WorkManager I cannot use because I am dealing with a time of 5 minutes and the minimum of it is 15 minutes. Unfortunately, this time is not flexible, I need it to be 5 minutes and allow exact updating even with the device inactive. Is there any way to achieve this behavior?

import a TextView and a CheckBox

I've been following a tutorial unfortunately this tutorial is 2 years old and (at timestamp 47:57) where the guy said to press Alt+Enter and import the TextView (called "tvTodoTitle" in this instance) just doesn't work on my version of Android Studio (details pasted below). When I Alt+Enter I just don't get the option "import" in the menu that drops down.

I can't not find out how to import the TextView object so that the code can use it. This also applies to the CheckBox object as well.

How do I import the TextView and the CheckBox that I created at the beginning of this tutorial?

Note: This is my first code in Android Studio after doing my Hello World, so I'm still a beginner in this IDE.

Android Studio Giraffe | 2022.3.1
Build #AI-223.8836.35.2231.10406996, built on June 29, 2023
Runtime version: 17.0.6+0-17.0.6b829.9-10027231 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 6.2.0-31-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 12
Registry:
external.system.auto.import.disabled=true
ide.text.editor.with.preview.show.floating.toolbar=false
Current Desktop: ubuntu:GNOME

Another Google service cancellation

The latest in the long line of products and services that Google have cancelled within a couple of years is "Pixel Pass": a 2 year subscription service which would get you a Pixel handset plus a bunch of paid Google services, at the end of which you could renew and get a newer Pixel to go with your continuing subscriptions. Except that nobody is ever going to test that last bit, because they've quietly closed the programme, both to new customers and renewals, 22 months after they started it.

I don't think anyone has any grounds to object because their existing 2 year subscription paid for their current phone rather than pre-paying for the upgrade. I suspect that there just wasn't enough uptake to justify it (though I don't remember ever seeing any marketing of it, so they may have themselves to blame for that). Just another tombstone in the cemetery of products and services Google dipped into but lost interest in or never committed to.

Transparent background FAB not allowing interaction/blocking interaction

Hey all I am trying to figure out why I am unable to interact with the background even though my app has a transparent background? The code below was modified from the official Google Android demos here.

Here is the code I am using:
Java:
class FabTransformationActivity : AppCompatActivity()  {

    private val viewModel: FabTransformationViewModel by viewModels()
private lateinit var fab: FloatingActionButton
private var mWindowManager:/*@@psggbk@@*/WindowManager? = null

private class ItemHolder(val parent: LinearLayout, listener: View.OnClickListener) {
val image: ImageView = parent.findViewById(R.id.image)
val name: TextView = parent.findViewById(R.id.name)

        init {
parent.setOnClickListener(listener)
        }
    }

private val menuOnClick = View.OnClickListener { v ->
val name = v.getTag(R.id.tag_name) as String

        fab.isExpanded = false
    }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
var params: WindowManager.LayoutParams
 
setContentView(R.layout.fab_transformation_activity)

val root: CoordinatorLayout = findViewById(R.id.root)
val sheet: CircularRevealCardView = findViewById(R.id.sheet)
val menuHolders: List<ItemHolder> = listOf(
ItemHolder(findViewById(R.id.menu_1), menuOnClick),
ItemHolder(findViewById(R.id.menu_2), menuOnClick),
ItemHolder(findViewById(R.id.menu_3), menuOnClick),
ItemHolder(findViewById(R.id.menu_4), menuOnClick)
        )

fab = findViewById(R.id.fab)

WindowCompat.setDecorFitsSystemWindows(window, false)

        val fabMargin = 16

ViewCompat.setOnApplyWindowInsetsListener(root) { _, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())

fab.updateLayoutParams<CoordinatorLayout.LayoutParams> {
                leftMargin = fabMargin + systemBars.left
                rightMargin = fabMargin + systemBars.right
                bottomMargin = fabMargin + systemBars.bottom
            }

sheet.updateLayoutParams<CoordinatorLayout.LayoutParams> {
                leftMargin = fabMargin + systemBars.left
                rightMargin = fabMargin + systemBars.right
                bottomMargin = fabMargin + systemBars.bottom
            }

            insets
        }
    
viewModel.items.observe(this) { items ->
            menuHolders.forEachIndexed { i, holder ->
if (items.size > i) {
                    val _item = items[i]

                    holder.parent.isVisible = true
holder.parent.setTag(R.id.tag_name, _item.name)
                    holder.name.text = _item.name

Glide.with(holder.image)
.load(_item.image)
.transform(CircleCrop())
.into(holder.image)
                } else {
                    holder.parent.isVisible = false
                }
            }
        }

        fab.setOnClickListener {
            fab.isExpanded = true
        }
    }

    override fun onBackPressed() {
if (fab.isExpanded) {
            fab.isExpanded = false
        } else {
            super.onBackPressed()
        }
    }
}

The layout:
XML:
<androidx.coordinatorlayout.widget.CoordinatorLayout
    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:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <!-- A FAB that expands into a sheet. -->
    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_margin="16dp"
        app:elevation="8dp"
        android:contentDescription=""
        app:srcCompat="@drawable/ic_add" />

    <!--
        A sheet that the FAB expands into.
        Use CircularRevealCardView to apply circular reveal effect.
    -->
    <com.google.android.material.circularreveal.cardview.CircularRevealCardView
        android:id="@+id/sheet"
        android:layout_width="256dp"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_margin="16dp"
        android:background="?attr/colorSurface"
        android:visibility="invisible"
        app:elevation="8dp"
        app:layout_behavior="@string/fab_transformation_sheet_behavior"
        tools:visibility="visible">

        <LinearLayout
            android:id="@+id/sheet_content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingTop="8dp"
            android:paddingBottom="8dp">

            <include
                android:id="@+id/menu_1"
                layout="@layout/menuitems" />

            <include
                android:id="@+id/menu_2"
                layout="@layout/menuitems" />

            <include
                android:id="@+id/menu_3"
                layout="@layout/menuitems" />

            <include
                android:id="@+id/menu_4"
                layout="@layout/menuitems" />

        </LinearLayout>

    </com.google.android.material.circularreveal.cardview.CircularRevealCardView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

I can interact with the FAB but when I try moving the background (which is just the standard Android home screen, I never moves.

App not running (can movie the home screen around): enter image description here

Now with the transparent fab: enter image description here

What can I change (or add) in order to get this to work? The goal is to have this FAB button floating regardless of what app is opened.

Filter

Back
Top Bottom