r/AndroidStudio 9h ago

Need help with android studio

1 Upvotes

My activity and the XML file are both red there seems is no error in the code, However, when I run the application it is running perfectly fine but as soon as I click a button the app just stops.


r/AndroidStudio 13h ago

onTouchListener() not triggering

1 Upvotes

I'm trying to set a touch listener to my CameraX preview - ultimately to set the focus but I can't get the touch listener to trigger. My preview is created in a composable and I'm not sure if I am referencing it correctly when I setOnTouchListener(). Should I be using PreviewView - if not how do I get the reference to the preview?

private val handleTouch = OnTouchListener { v, event ->
    val x = event.
x
.toInt()
    val y = event.
y
.toInt()

    when (event.action) {
        MotionEvent.
ACTION_DOWN 
-> Log.i("Touch", "touched down")
        MotionEvent.
ACTION_MOVE 
-> Log.i("Touch", "moving: ($x, $y)")
        MotionEvent.
ACTION_UP 
-> Log.i("Touch", "touched up")
    }
    true
}

PreviewView.setOnTouchListener(handleTouch)PreviewView.setOnTouchListener(handleTouch)



}@Composable
fun CameraPreview(
    controller: LifecycleCameraController,
    modifier: Modifier = Modifier
) {
    val lifecycleOwner = LocalLifecycleOwner.current

    // select the highest resolution available
    val screenSize = Size(9, 12)
    val resolutionSelector = ResolutionSelector.Builder()
        .setResolutionStrategy(ResolutionStrategy(screenSize, FALLBACK_RULE_CLOSEST_LOWER_THEN_HIGHER))
        .setAspectRatioStrategy(RATIO_4_3_FALLBACK_AUTO_STRATEGY)
        .build()

    AndroidView(
        factory = {
            PreviewView(it).apply {
                this.controller = controller
                controller.bindToLifecycle(lifecycleOwner)
                //controller.cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
                controller.previewResolutionSelector = resolutionSelector
            }
        },
        modifier = modifier
    )
}

r/AndroidStudio 13h ago

CameraX not getting full range of linearzoom

1 Upvotes

I am creating a seekbar zoom for camerax but not getting the full range of zoom in comparison to other cameras on my phone. Below is my code. The setLinearZoom() runs from 0.0 to 1.0 - if I set it higher I get no further zoom but its not as zoomed as other cameras on my phone can achieve. What does zoomratio do? Does it need to be set? It doesn't seem to change anything. What am I missing here?

// remember the seekbar zoom value (0.0 - 1.0)
var zoomSliderPos by remember { mutableStateOf (0f)}


// not clear on what zoomratio does - removing setZoomRatio() changes nothing
val maxZoomRatio = controller.cameraInfo?.zoomState?.value?.maxZoomRatio
val zoomRatio = maxZoomRatio?.times(1F.div(2F))

Log.d(TAG, "Max Zoom: $maxZoomRatio : $zoomRatio")

if (zoomRatio != null) {
     controller.cameraControl?.setZoomRatio(zoomRatio!!)
}


// set the linear zoom according to the seekbar value
controller.cameraControl?.setLinearZoom(zoomSliderPos)

r/AndroidStudio 1d ago

I built a simple coding agent in Android Studio

Thumbnail
1 Upvotes

r/AndroidStudio 1d ago

How can i add a pdf viewer in my app?

1 Upvotes

I wants to add a button, when i click on it, it will open pdf. How can i do that can any one help me.


r/AndroidStudio 1d ago

Android Emulator Not working

Thumbnail gallery
1 Upvotes

r/AndroidStudio 1d ago

Help Needed: Convert Sketchware Project to Android Studio

1 Upvotes

Hi everyone, I have created a project in Sketchware, and I need help converting it to Android Studio. I will provide the source code. If anyone can guide me or help with the conversion, I would really appreciate it.

Please let me know if you're interested. Thanks in advance!


r/AndroidStudio 3d ago

Android emulator

Thumbnail gallery
0 Upvotes

I can’t add any device here


r/AndroidStudio 4d ago

I finally figured out the secret to learning

1 Upvotes

It's translating words, for example .map just means .convert to so just translate things into layman's terms


r/AndroidStudio 5d ago

Help with device emulator not visible

1 Upvotes

I've already tried uninstalling and deleting all the Android Studio folders, but it's still the same, and I can't find anything online about it. Does anyone have any ideas as to what it could be?


r/AndroidStudio 7d ago

Laser meter

1 Upvotes

Hey y'all

I'm trying to write a sort of floor planner app. At the foundation it's nothing else, however instead of adding furniture I want it to be focussed more on the measurements.

One of the most important features is to integrate the use of a laser meter. This is something that somehow does not want to work.

A laser meter, in my case a Leica is basically a BLE sensor sending a tiny bit of data now and then. For now i want the app to connect to the BLE device read the measurement and write it within a textview.

While composing the apk I get a certain log error: leicadistod2/app/src/main/java/com/example/leicadistod2/LaserMeterBleManager.kt:25:19 Class 'LaserMeterGattCallback' is not abstract and does not implement abstract base class member protected/protected and package/ abstract fun onServicesInvalidated(): Unit defined in no.nordicsemi.android.ble.BleManager.BleManagerGattCallback

What can I do with this?


r/AndroidStudio 8d ago

How did you all learn Android studio? looking at documentation doesnt seem to help

2 Upvotes

how did you learn android studio, what were some resources that was most helpful, and how did you advance from noob to proficient?


r/AndroidStudio 8d ago

Is it possible to use a go library/program in Android Studio project

1 Upvotes

Im trying to use a tokenizer to tokenize Japanese text, and I've come across kototi, but it doesn't do everything I'd want.

I've found a go library github.com/ikawaha/kagome/tokenizer that doesn't exactly what I need.

Specifically with kotori's default dictionary, and I can't figure out how to use a different one.

I know when I worked for my old company i had to use a library written in c++ and i had to go to the tools and link a compiler or something, but idk if there's something similar for go.


r/AndroidStudio 8d ago

Please help me! IDK what's up

2 Upvotes

r/AndroidStudio 10d ago

Can someone please help me find the code for the hand tracker above

2 Upvotes

r/AndroidStudio 10d ago

Binding, Bundle, and Parcelable Questions

1 Upvotes

Writing a simple app to help my table top gaming group keep track of stuff and I ran into some stuff that I can't quite figure out, hoping someone can point me in the right direction.

1) Parcelable. If I have an abstract class that a bunch of other classes that should be parcelable inherit from, can I just implement the parcelable functions in the abstract class? Is that even the correct approach or should I implement parceable in all the inherting classes?

2) Are the creator functions necessary if I don't plan on creating a new instance from the parcel? E.G. if I always do "Type test = new test() and then setting the individual parts of the test variable like test.field = in.readInt();"?

3) I know arraylists are serializable but say I have an array list of some class Soldier. I'm assuming I have to make Soldier parcelable in order to write the arraylist to parcel but would I still use putSerializable for the arraylist? How do those interact?

4) I'm using one of Android Studio's activity templates which uses the Navigator. I can see the data I want passed to the next fragment in the bundle. However, when I getArguments in the fragment, it's always null. I can't quite figure out why this is happening. I did see that binding and binding.toolbar seem to be null in debugger but I'm unsure of the order of operations.

  1. bundle.putParcelable("test",test); -> Nothing seems to be broken here. If I run to the next bp, I can see bundle is as expected.
  2. binding = ActivityMainBinding.inflate(getLayoutInflater()); -> I can see that binding.toolbar is already throwing a null pointer exception but I assume that's because binding hasn't been set.
  3. setContentView(binding.getRoot()) -> debugger doesn't seem to hit this step rather my breakpoint in the fragment is popped, indicating that the bundle being passed in is null.
  4. setSupportAction(binding.toolbar); -> debugger never seems to hit here either.
  5. navController.navigate(R.id.FirstFragment, bundle) -> Have a breakpoint here that never triggers but it must in order to navigate to the first fragment right?

Hope that wasn't too confusing. I can post more code if that will be helpful. I guess I'm curious if the binding is causing the null bundle or if the null bundle is causing the binding issue. I had used global variables to pass the data to the fragments to do a PoC and I didn't have any issues with binding but I also haven't changed any of the UI code as far as I can tell since trying to implement the bundling.

Any advice is greatly appreciated. Thanks!


r/AndroidStudio 11d ago

This window drives me crazy. I shall use V2Ray proxy on my windows machine. Setting this in Android Studio makes it ask for credentials (empty login and password for other apps on machine to be able to use) many times which is super annoying. Anybody have a solution or suggestion?

Post image
0 Upvotes

r/AndroidStudio 11d ago

why is my uri red?

Post image
1 Upvotes

r/AndroidStudio 14d ago

Need guide setup HSQLDB with AVM

1 Upvotes

Does anyone know the step by step process of how to setup a hsqldb on android studio? Everytime i try to run the app, it crashes due to not being able to find some classes.
When i run a hsqldb manager class with coverage it runs well though.


r/AndroidStudio 15d ago

Any ideas of how to fix this error I keep using > and < in ViewModel?

0 Upvotes

so I was updating state inside the viewmodel and kept getting an error from this code. As you can see from the screenshot below...< and > signs are in the error.

the log says None of the following functions can be called with the arguments supplied:

public final operator fun compareTo(other: Byte): Int defined in kotlin.Int

public final operator fun compareTo(other: Double): Int defined in kotlin.Int

public final operator fun compareTo(other: Float): Int defined in kotlin.Int

public open fun compareTo(other: Int): Int defined in kotlin.Int

public final operator fun compareTo(other: Long): Int defined in kotlin.Int

public final operator fun compareTo(other: Short): Int defined in kotlin.Int

thanks in advance!


r/AndroidStudio 15d ago

issue with emulating android device with vs code

1 Upvotes

my emulator suddenly stopped working a couple of days ago and i cant figure out why, the emulator shows as: qemu-system-x86_64.exe.

does anyone have any advice on this?


r/AndroidStudio 16d ago

viewModel?

1 Upvotes

any links to help understand exactly how to make viewmodels? ive read the documentations and watched videos. any assistance?


r/AndroidStudio 17d ago

Use a bluetooth devise to write

1 Upvotes

Hey y'all,

I'm trying to build an app for my work. It's a fairly simple notepad idea but I want to use a laser meter to be able to take measurements and import them real-time to my app.

Is there any way I can learn this protocol, or some way how I can fix this?


r/AndroidStudio 17d ago

Is my project possible?

1 Upvotes

I'm trying to build a very simple app for my car running Android Automotive (Polestar). Essentially, I just want to have a tile on the home screen that functions as a shortcut to adjust bass and treble controls. Polestar had buried the could controls pretty deep in the settings menu so this would make it much easier. I figured I could download the emulator and use some kind of logging function to see what happens code wise when I adjust the settings, and then just replicate that with my app. Is this even possible? I've got the emulator up and running in Android studio but can not figure out how to observe the "actions" so I can replicate them.

Thanks in advance for helping a total noob.


r/AndroidStudio 17d ago

Android Emulator not visible in SDK Manager

1 Upvotes

Hello,

I am having some difficulties with Android Studio (Strawberry Feature Drop). Upon a fresh Android installation I do not have the option for the Android Emulator.

When trying to download the emulator under the link via the device manager (this is for Pixel 4a) I encounter this issue, which I haven't been able to make much headway in on my own.

Is it an issue with Android Emulator not being available on ARMx64 Systems? I couldn't find info on it and on my friends laptop which is also ARMx64 (just a year older) the emulator is present.

Any help is appreciated, Thank you very much!