• Breaking News

    Thursday, May 12, 2022

    Android Dev - Google Code Scanner - Scan QR/Barcodes from the apps without the camera permission - Google I/O 2022

    Android Dev - Google Code Scanner - Scan QR/Barcodes from the apps without the camera permission - Google I/O 2022


    Google Code Scanner - Scan QR/Barcodes from the apps without the camera permission - Google I/O 2022

    Posted: 11 May 2022 11:40 PM PDT

    Horologist is a group of libraries that aim to supplement Wear OS developers with features that are commonly required by developers but not yet available.

    Posted: 12 May 2022 08:18 AM PDT

    TargetSdkVersion 34 will replace `onBackPressed()` with the newly added OnBackInvokedCallback in Android 13, and `onBackPressed()` + `KEYCODE_BACK` will stop working

    Posted: 12 May 2022 02:00 AM PDT

    New Firebase extensions for building and managing in-app purchases

    Posted: 12 May 2022 08:27 AM PDT

    [Help] UseCases with Hotstreams

    Posted: 12 May 2022 11:55 AM PDT

    Hi Devs,
    hope you are doing all fine.

    I started learning about use cases and I do like them.

    While playing with them, I am facing an issue to decide how to provide hot streams when using usecases.

    class SomeRepositoryImpl: Repository { val data = MutableStateFlow<Boolean>(false) } class GetSomeData(repository: Repository) { operator fun invoke(): Boolean { return repository.data.value } } 

    What It feels wrong here, is that I am returning a hot stream whether I expect use cases always to return once (a failure or success) result.

    Now, I am interested to collect|observe always to that data not only once.
    I could come with the idea of another usecase such as

    class ObserveDataUseCase(repository: Repository) { operator fun invoke(): StateFlow<Boolean> { return repository.data } } 

    But I am not sure about this one though.

    Now, the question is, how would you deal with such situation?

    submitted by /u/butritxheladini
    [link] [comments]

    Questions about Dependency Injection from a Beginner

    Posted: 12 May 2022 08:07 AM PDT

    I am new to android, so now i started learning about Dependency Injection. I see how providing dependencies in a constructor, instead of creating them inside a class, can make class more reusable, modular, and easier to test.

    But it also adds a problem: you have to provide dependencies by hand every time you need to use that class. And in majority of cases, dependencies don't change, so you end up with a lot of duplicate code. DI frameworks, or container may solve this problem, but it adds complexity.

    What if you define default values of dependencies in a constructor, to the ones that are used most commonly, and then redefine the values, only when you need to change dependencies, when creating the object? That way, you get the ability to set your own dependencies, and avoid duplicate code.

    For example, let's use Car and Engine classes:

    class Engine(){

    fun start(){println("Starting engine!")}}

    // 1. Without DI

    class Car(){

    private val engine = Engine()

    fun start() = engine.start()

    }

    val car = Car()

    car.start() //"Starting engine!"

    //2. With DI

    class Car(val engine: Engine){

    fun start() = engine.start()

    }

    val engine = Engine()

    val car = Car(engine)

    car.start() //"Starting engine!"

    //3. DI with default values for parameters

    class Car(val engine: Engine = Engine()){

    fun start() = engine.start()

    }

    val engine = Engine()

    val car = Car(engine)

    car.start()

    //or

    val car = Car()

    car.start()

    //4. Default values for parameters in case the variable must be lateinit, for example if the object must be created inside a onCreate() method in activity.

    class Car(val cEngine: Engine? = null){

    lateinit var engine: Engine //cannot be set inside constructor because it is lateinit. lateinit is needed because it is initialized inside a method

    init{onCreate()} // Activity itself calls this method automatically

    fun onCreate() { // Method like in activity.

    engine = cEngine ?: Engine()}

    fun start() = engine.start()

    }

    val engine = Engine()

    val car = Car(engine)

    car.start()

    //or

    val car = Car()

    car.start()

    What do you guys think about this approach to Dependency Injection? I realize that for very big projects, with multiple developers, i would need to learn a DI framework. But for small personal project, is it good, or bad? Why?

    submitted by /u/Radlib123
    [link] [comments]

    What's new in Jetpack Compose

    Posted: 11 May 2022 01:52 PM PDT

    ASO Tips And Tricks, Please? [NEWBIE][2022]

    Posted: 12 May 2022 05:16 AM PDT

    Hello guys,

    My first app got play store approval, and I am pleased. I did a little research about ASO. and tried to do my best to optimize it properly. I have used tools like sensor tower, app Annie and app tweak for generating a proper ASO-friendly app title and description. And I did eye-catching app thumbnails and screenshots as well. But other than that, what can I do to improve my ASO performance?

    submitted by /u/Snorlax_lax
    [link] [comments]

    Integrate Lucene in android app for offline full-text search

    Posted: 12 May 2022 10:43 AM PDT

    Good day everyone, I need some advise. I want to develop an app ( a legal app for law practitioners), which would need to store thousands of files ( pdf, html) locally, and be able to parse these thousands of files and perform full-text search. Then users will be able to search for key words ( e.g rape, murder, theft etc ) and get results for all the files containing these key words.

    To be honest I want to use React native to develop this app. I know this isn't the appropriate sub-Reddit for this post, but I'm really at wits-end here and haven't gotten much headway.

    I was advised to use Apache Lucene for this, but I'm not so familiar with Java nor native android development to figure out how to actually integrate it with my app. I was thinking that if I could somehow integrate Lucene into my app, then I would be able to use react native's NativeModule system to expose instances of native code ( Lucene's Java implementation) to JavaScript as JS objects which would allow me to execute native code from within JS.

    Please pardon me if I didn't really explain my problem so well.

    submitted by /u/Brave_Tomatillo974
    [link] [comments]

    Final Reminder: Mega Online Drive for Android Developers 2022

    Posted: 12 May 2022 06:18 AM PDT

    Final Reminder: Mega Online Drive for Android Developers 2022

    Last day to apply!

    If you can translate designs and wireframes into high-quality code, we are looking for you!Come join us if you can:
    ✔ Design, build and maintain high performance, reusable, and reliable code
    ✔ Ensure the best possible performance, quality, and responsiveness of the application
    ✔ Identify and correct bottlenecks and fix bugs.
    ✔ Help maintain code quality, organization, and automatization
    ✔ Collaborate with cross-functional teams to define, design, and ship new features.
    ✔ Understand business requirements and translate them into technical requirements.

    Apply Today!

    Here is the registration form link - https://glxy.to/android

    https://preview.redd.it/vqrfew1ap1z81.png?width=2160&format=png&auto=webp&s=d83dd0e05b7f62b6b461f4ddb8a7922a14be573d

    submitted by /u/techvirtualus
    [link] [comments]

    How do you contact Google's Policy support team about an app suspension?

    Posted: 12 May 2022 05:52 AM PDT

    I made a post earlier about my Tetris-clone game being suspended by a DMCA takedown and receiving a strike against my account. As I said I didn't even know that Tetris-type of gameplay was copyrighted.

    What I want to do now is contact Google and ask them if I can update the app to be compliant so I can remove the strike. I tried both Email and Chat and they both tell me they cannot help and that I should contact the "Policy support team" instead. How do I contact them? Google's links only lead to the appeals page.

    submitted by /u/HiDiNoWro
    [link] [comments]

    I am an Android Developer residing in SouthEast Asia, currently applying for remote jobs in Europe and North America. Can you provide some feedback on my resume?

    Posted: 11 May 2022 09:39 AM PDT

    Sharing URL using NFC

    Posted: 12 May 2022 03:07 AM PDT

    Do anyone know how to make my android devices shares a URL link when other android devices scan using NFC when it approach to my apps?

    Thanks in advance.

    submitted by /u/Zealousideal-Cup-744
    [link] [comments]

    Filtering a recyclerview/Livedata list part 2 (Help)

    Posted: 12 May 2022 07:27 AM PDT

    @HiltViewModel class CharactersViewModel @Inject constructor( private val repository: Repository ) : ViewModel() { private val _spinner = MutableLiveData<Boolean>(false) val spinner: LiveData<Boolean> = _spinner var season = 0 private val _errorText = MutableLiveData<String?>() val errorText: LiveData<String?> = _errorText private val _characters = MutableLiveData<List<BreakingBadCharacterItem>?>() val characters: LiveData<List<BreakingBadCharacterItem>?> = _characters.distinctUntilChanged().map() { seasons -> when (season) { 0 -> { seasons?.filter { it.appearance.any() } } 1 -> seasons?.filter { it.appearance.any { it == season } } 2 -> seasons?.filter { it.appearance.any { it == season } } 3 -> seasons?.filter { it.appearance.any { it == season } } 4 -> seasons?.filter { it.appearance.any { it == season } } 5 -> seasons?.filter { it.appearance.any { it == season } } else -> { seasons } } } init { getAllCharacters() season = 0 } private fun getAllCharacters() = viewModelScope.launch { try { _spinner.postValue(true) val response = repository.loadBBCharacters() _characters.postValue(response) } catch (error: BreakingError) { _errorText.postValue(error.message) } finally { _spinner.postValue(false) } } fun onErrorTextShown() { _errorText.value = null } } 

    @AndroidEntryPoint class CharactersFragment : Fragment(R.layout.fragment_character_list) { private lateinit var binding: FragmentCharacterListBinding private val recyclerViewAdapter = MyCharactersRecyclerViewAdapter() private val viewModel: CharactersViewModel by viewModels() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { binding = FragmentCharacterListBinding.inflate(inflater, container, false) setHasOptionsMenu(true) return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) showError() setupRecyclerView() navigateToDetails() } override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) { R.id.menu_filter -> { showFilteringPopUpMenu() true } else -> false } override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { inflater.inflate(R.menu.characters_fragment_menu, menu) val searchItem: MenuItem = menu.findItem(R.id.menu_item_search) val searchView = searchItem.actionView as SearchView searchView.apply { setOnQueryTextListener(object : SearchView.OnQueryTextListener { override fun onQueryTextSubmit(queryText: String): Boolean { Log.d("MainActivity", "QueryTextSubmit: $queryText") return false } override fun onQueryTextChange(queryText: String): Boolean { Log.d("MainActivity", "QueryTextChange: $queryText") recyclerViewAdapter.filter.filter(queryText) return true } }) } } private fun navigateToDetails() { recyclerViewAdapter.setOnItemClickListener { val action = CharactersFragmentDirections.actionCharactersFragmentToCharacterDetailsFragment(it) findNavController().navigate(action) } } private fun setupRecyclerView() { binding.list.apply { layoutManager = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL) adapter = recyclerViewAdapter viewModel.characters.observe(viewLifecycleOwner) { it?.let { recyclerViewAdapter.updateList(it) Log.d("TAG", "onViewCreated: ${it.size}") } } } } private fun showError() { viewModel.spinner.observe(viewLifecycleOwner) { value -> value.let { show -> binding.spinner.visibility = if (show) View.VISIBLE else View.GONE } } viewModel.errorText.observe(viewLifecycleOwner) { text -> text?.let { binding.errorTextView.apply { this.text = text visibility = View.VISIBLE } binding.list.visibility = View.GONE viewModel.onErrorTextShown() } } } private fun showFilteringPopUpMenu() { val view = activity?.findViewById<View>(R.id.menu_filter) ?: return PopupMenu(requireContext(), view).run { menuInflater.inflate(R.menu.filter_seasons, menu) setOnMenuItemClickListener { when (it.itemId) { R.id.one -> { viewModel.season = 1 Toast.makeText(requireContext(), "Season One", Toast.LENGTH_SHORT) .show() } R.id.two -> { viewModel.season = 2 Toast.makeText(requireContext(), "Season Two", Toast.LENGTH_SHORT) .show() } R.id.three -> { viewModel.season = 3 Toast.makeText(requireContext(), "Season Three", Toast.LENGTH_SHORT) .show() } R.id.four -> { viewModel.season = 4 Toast.makeText(requireContext(), "Season Four", Toast.LENGTH_SHORT) .show() } R.id.five -> { viewModel.season = 5 Toast.makeText(requireContext(), "Season Five", Toast.LENGTH_SHORT) .show() } else -> { viewModel.season = 0 Toast.makeText(requireContext(), "All Seasons", Toast.LENGTH_SHORT) .show() } } true } show() } } } 

    So I thought I figured it out but unfortunately I've been struggling with it for the past 2 days.

    Could someone please help me understand what I'm doing wrong here???

    I'm trying to filter the list based on the seasons, so it would only show characters from the specific season chosen.

    Any help would be appreciated!

    submitted by /u/Cybersnake
    [link] [comments]

    Android code guidelines

    Posted: 12 May 2022 06:23 AM PDT

    Hi everyone what is the best #Android code guideline that you know? For naming android components, resources, kotlin language, graddle, quote marks, etc...

    submitted by /u/DiegoValdivia
    [link] [comments]

    Why do some source codes look so complicated & feel like it can be done in a simple way?

    Posted: 12 May 2022 12:19 AM PDT

    An example Lots of base classes for activity, fragment, view model etc. Is it really need to be done that way?

    submitted by /u/jaroos_
    [link] [comments]

    Since upgrading Android Studio to chipmunk, wireless debugging won't connect..

    Posted: 12 May 2022 12:16 AM PDT

    Anyone facing the same issue? Did you manage to fix it?

    submitted by /u/gottlikeKarthos
    [link] [comments]

    New Features in Android Studio Electric Eel

    Posted: 11 May 2022 12:10 PM PDT

    13 Things to know for Android developers at Google I/O!

    Posted: 11 May 2022 04:16 PM PDT

    When to download data needed for my app to run?

    Posted: 12 May 2022 04:49 AM PDT

    Basically I need to download data, which I will store in Database and my app will then do stuff with this data.

    I already created Worker class to download it and store it, but I have no idea when to run doWork().

    submitted by /u/siwanar
    [link] [comments]

    Looking for in-app chat tutorials or SDK

    Posted: 12 May 2022 04:40 AM PDT

    Looking to add in-app chat between users. What's a good and cheap SDK? I looked at https://www.androidhive.info/2014/10/android-building-group-chat-app-using-sockets-part-1/ and wondering if this is still mostly relevant. Thanks in advance

    submitted by /u/acedelaf
    [link] [comments]

    State in Jetpack Compose workshop

    Posted: 11 May 2022 02:37 PM PDT

    Build was configured to prefer settings repositories over project repositories but repository 'MavenRepo' was added by build file 'app/build.gradle' --problem in Android Studio

    Posted: 12 May 2022 02:43 AM PDT

    Build was configured to prefer settings repositories over project repositories but repository 'MavenRepo' was added by build file 'app/build.gradle' --problem in Android Studio

    I've been having this problem in my Android Studio from last 4 days. I tried every possible solution on google but nothing helps. One problem leads to another and nothing works out. I tried clearing cache, installed the app multiple times and what not! Could anyone please help me resolve it?

    https://preview.redd.it/ecl9mluin0z81.png?width=1839&format=png&auto=webp&s=cc0a838fdbcafc2464a5b5c197e9e2a2938e5be0

    submitted by /u/Soggy_Ratio_8426
    [link] [comments]

    Android Studio Electric Eel Canary 1 now available

    Posted: 11 May 2022 10:58 AM PDT

    navigation destination "route" is not a direct child of this NavGraph when add startDestination parameter.

    Posted: 12 May 2022 02:01 AM PDT

    Hello, everyone. I am doing a project that need a function that: open the app intent through nfc tag. According to the NDEF message to open compose.

    Every is alright when I set startDestination without parameter like "TestScreen"

    and is fine when I call navController.navigate(route = TestScreen?number=5) too.

    but when I set startDestination as "TestScreen?number=5" it will show "navigation destination "route" is not a direct child of this NavGraph" which means the compose isn't in the NavHost.

    Following is my code.

    @Composable fun MainScreen() { val splashRoute = "Screen.SplashScreen.route" // It's fine val testRoute= "TestScreen?number=5" // It'll cause crash. NavHost( navController = navController, startDestination = startDestination ) { composable(route = Screen.SplashScreen.route) { SplashScreen(navController = navController) } composable( route = Screen.TestScreen.route + "?" + "number={number}", arguments = listOf( navArgument( name = "number" ) { type = NavType.IntType defaultValue = -1 } ) ) { TestScreen(navController = navController) } } navController.navigate(route = testRoute) // It's fine, too. } 

    Is setting startDestination with parameter is wrong? Or maybe there are some mistakes I made?

    Thanks everyone to read.

    submitted by /u/z19970615
    [link] [comments]

    No comments:

    Post a Comment