I'm trying to follow code samples I've found on the web (Gabriel Tanner, Ray Wenderlich, Official Introduction), but I usually get stymied on the very first line:
CameraX.unbindAll()
Compiler complains that unbindAll() is an unresolved reference (Kotlin). The sample code from here is the only reference that does not use it. But all the other sample codes have it, including Google's own videos.
I can't even find any references to this method in Google's docs. What happened? Have changes in the past few months already made all these excited introductions obsolete?
I'm evaluating CameraX to see if it's worth our company's time to switch our code from Camera2 to CameraX. If things are changing this fast, what are the chances that significant code changes will happen in the future?
CameraX has gone through some changes since it was first introduced last year, this is normal since it was still in Alpha, the API surface was changing a bit throughout the alpha versions, but since it's gone into beta, its public API has become more stable.
Going back to your question, binding and unbinding use cases in CameraX is no longer done through the CameraX class, but instead, it is now done using ProcessCameraProvider.bindToLifecycle() to bind one or multiple use cases to a lifecycle, ProcessCameraProvider.unbind() to unbind one or multiple use cases, and ProcessCameraProvider.unbindAll() to unbind all bound use cases.
The tutorials you're using as reference are outdated, even the video from last year's google I/O is outdated, since the code snippets in it are referencing CameraX's first alpha version. However, the link of the codelab you mentioned is -almost- up to date, it's the official CameraX codelab that's maintained by Google. You can also take a look at the official documentation of CameraX, it's more up to date that the tutorials you referenced.
Related
In most of the samples regarding Android View Model and lazy init nobody refers to the parameters which can be used in by Lazy.
From the Kotlin docu:
If you're sure that the initialization will always happen in the same thread as the one where you use the property, you can use LazyThreadSafetyMode.NONE. It doesn't incur any thread-safety guarantees and related overhead.
I can not recall any cases in my project where I access ViewModel properties outside the MainUIThread, so I'm intending to now use LazyThreadSafetyMode.NONE everywhere in my ListFragmentViewModel, but I'm not seeing Google's samples doing this at all, am I missing some cons? The Google IO App 2022 uses LazyThreadSafetyMode.PUBLICATION in some part of the code, but could not find any usages of LazyThreadSafetyMode.NONE.
I've recently had some tasks requiring that I need to log an Android app for some events, like adding to cart, checkout, signing in to the app, pressing on a specific button, etc... to Facebook and Firebase platforms.
Since these are non-functional requirements, I figured out it could be a good idea to start implementing the AOP (Aspect Oriented Programming) method, so events can be intercepted without changing any code in the app.
I've made my research and found out that you could implement AOP using either the AspectJ lang (which is compiled to Java Bytecode and can talk to java directly), or AspectJ annotations like #Before #After and #Around to intercept the pointcuts.
However, I have read some articles like This one And This one, they don't seem to be working for me, the code before of after the pointcut calls do not get invoked at all. I feel like I might have something missing or outdated in the build.gradle aspect code that is mentioned in the first article (which is 8 years old really).
I won't be providing any code here since I've tried the exact same examples in the tutorials and didn't work for me.
I'm asking for someone recently implemented AOP in his Android app.. And could provide me with some steps that I can follow, so I can get the code in the aspects invoked and working.
Also, I've seen some people on the internet trying to implement the aspects in another Android module, and some in another src directory, if someone would explain the difference? And since I'm using Firebase and Facebook dependencies to log the events, wouldn't making the aspects in a different module affect me in any way?
Also, if anyone knows if I'm approaching the best way here to log the events (for Firebase and Facebook), or there could be better? I've went to AOP since I don't feel like changing the existing code to log some events is ideal.
Please, and thank you.
exoplayer.setThrowsWhenUsingWrongThread(false) is deprecated in Exoplayer latest version, is there any alternative to it because when I remove it then it gives,
java.lang.IllegalStateException: Player is accessed on the wrong thread.
Current thread: 'DefaultDispatcher-worker-1
Expected thread: 'main'
exoplayer works fine if I use it, but it's deprecated.
Thank you for your Help!
setThrowsWhenUsingWrongThread() has become deprecated for the following reason according to the official documentation: "Disabling the enforcement can result in hard-to-detect bugs. Do not use this method except to ease the transition while wrong thread access problems are fixed." The official release notes extend on this commentary by mentioning the method will be removed entirely upon the next major release.
There's no alternative outside of complying to the library's strict single-thread paradigm. Please see the Hello World's note on threading and the threading model section of the official documentation. You can employ setThrowsWhenUsingWrongThread(false) in the meantime as it's only deprecated, but you'll need to comply if you would like to utilize upcoming features.
My work has asked me to try out the NNPack math library (see it on Github at https://github.com/Maratyszcza) and report on its suitability for our Android project. I've found no documentation either on Github or in the source code, and functions such as matrix multiplication involve so many unexplained parameters that it's difficult to impossible to perform even the simplest operation.
A Google search hints that NNPack is in use by many people. Is this in fact right, and if so, how did they learn how to use it?
Can anybody please explain me what is the difference between cocos2d-android and cocos2d-android-1? What are the functionalities differ between them? And the related details.. I was searching, but not yet get anything appropriate to it..
The main difference is that cocos2d-android is basically dead, or at least it has had no activity since November 16, 2010.
The cocos2d-android-1 branch was created because of a lack of activity in the cocos2d-android version. The code is hosted on github and the commit log shows at least a few commits per months. It's not as frequently updated as one would hope it to be, but it's better than nothing.
Unfortunately both versions are still based on cocos2d-iphone 0.99.4 which was released in July 2010. So if you absolutely want to develop Android apps in Java, use cocos2d-android-1. If Java is not a deciding factor for you, then cocos2d-x (C++) will be the better choice since it is frequently updated and has financial backing.