android-jetpack

Can I record video with CameraX (Android Jetpack)?

你。 提交于 2019-11-30 05:17:26
问题 Google has released the new CameraX library as part of Jetpack. It looks great for taking pictures, but my use case also require making video's. I tried googling for that, but couldn't find anything. So, is it possible to record videos with the CameraX Jetpack library? 回答1: Yes, we can record video using CameraX . I have tried to implement myself with help of Github demo for CameraX. Please refer below code may it helps you. Config for Video in CameraX: val videoCaptureConfig =

Android JetPack navigation with multiple stack

烂漫一生 提交于 2019-11-30 04:04:34
I'm using Jetpack Navigation version 1.0.0-alpha04 with bottom navigation. It works but the navigation doesn't happen correctly. For example, if I have tab A and tab B and from tab A I go to Page C and from there I go to tab B and come back to tab A again, I will see root fragment in the tab A and not page C which does not what I expect. I'm looking for a solution to have a different stack for each tab, so the state of each tab is reserved when I come back to it, Also I don't like to keep all this fragment in the memory since it has a bad effect on performance, Before jetpack navigation, I

Android Jetpack Navigation with ViewPager and TabLayout

荒凉一梦 提交于 2019-11-30 02:20:14
For a new app i use Jetpack Navigation Library to implement proper back navigation. The first level of navigation is a navigation drawer which works fine with jetpack navigation as described in the documentation. But there is another level of navigation implemented with ViewPager and TabLayout. The fragments switched by the TabLayout contain additional linear navigation hierarchy. However, there seems to be no support for ViewPager/TabLayout in Jetpack Navigation. A FragmentPagerAdapter has to be implemented and the managed back stack ends when switching tabs. There is a disconnect between the

Dynamic ActionBar title from a Fragment using AndroidX Navigation

对着背影说爱祢 提交于 2019-11-30 01:41:33
I am using the new Navigation component from Android Jetpack. The root Activity setup is quite simple: override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) setSupportActionBar(toolbar) val navController = findNavController(R.id.navigationFragment) setupActionBarWithNavController(navController) bottomNavigationView.setupWithNavController(navController) } It works well when the Fragment's title is defined in the navigation graph. But for one Fragment, I want to set the title dynamically. I tried with findNavController()

Android P visibilityawareimagebutton.setVisibility can only be called from the same library group

半城伤御伤魂 提交于 2019-11-29 22:44:01
I'm trying to use the new Android P FloatingActionButton that's part of the com.google.android.material.floatingactionbutton.FloatingActionButton and I'm getting this warning: VisibilityAwareImageButton.setVisibility can only be called from the same library group (groupId=com.google.android.material) import com.google.android.material.floatingactionbutton.FloatingActionButton import android.view.View class MainActivity : AppCompatActivity() { lateinit var demoFab: FloatingActionButton override fun onCreate(savedInstanceState: Bundle?) { demoFab = findViewById(R.id.demoFab) demoFab.visibility =

How to create LiveData which emits a single event and notifies only last subscribed observer?

孤街浪徒 提交于 2019-11-29 11:31:32
I created live data which emits a single event as in this example . My question is next: How to notify only last subscribed observer when the value in the LiveData changes? What comes to my mind is to store observers in the linked list in SingleLiveData class and then to call super.observe only if a passed observer is the same as the last element of the list. I'm not sure if this is the best approach. I want to use this mechanism to propagate FAB click events from activity to the fragments which are shown inside of the ViewPager. Fragments are dynamically added to view pager adapter, so let's

Synchronous or Asynchronous Rxjava inside the Worker (from WorkManager component) what's the right choice?

早过忘川 提交于 2019-11-29 02:18:16
问题 I'm new to the new architecture component WorkManager, I do my API calls via Retrofit and RxJava. My use case here is to get new posts from the Backend, then show notification, and update a widget. So the code inside doWork() method from the Worker class, may look like something like this. @NonNull @Override public Result doWork() { AppDependencies appDependencies = new AppDependencies((Application) getApplicationContext()); Repository repository = appDependencies.getRepository(); repository

Android WorkManager api for running daily task in Background

眉间皱痕 提交于 2019-11-28 09:54:15
I need to call one API daily in the background even if the app is closed. I have seen about WorkManager API. For my scenario, I tried PeriodicWorkRequest but unfortunately, it's not working as my expected result. What I did is I used this code in the Application class PeriodicWorkRequest.Builder myWorkBuilder = new PeriodicWorkRequest.Builder(MyWorker.class, 24, TimeUnit.HOURS); PeriodicWorkRequest myWork = myWorkBuilder.build(); WorkManager.getInstance().enqueue(myWork); But it's running repeatedly for 11 times when the app is open for the first time after that, it's not running after 24 hrs.

Is it possible to set startDestination conditionally using Android Navigation Architecture Component(Android Jetpack)?

六眼飞鱼酱① 提交于 2019-11-28 08:13:57
I am using Navigation from Android Jetpack to navigate between screens. Now I want to set startDestination dynamically. I have an Activity named MainActivity And two Fragments, FragmentA & FragmentB. var isAllSetUp : Boolean = // It is dynamic and I’m getting this from Preferences. If(isAllSetUp) { // show FragmentA } else { //show FragmentB } I want to set above flow using Navigation Architecture Component. Currently I have used startDestionation as below but it’s not fulfilling my requirement. <navigation xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas

Manually clearing an Android ViewModel?

限于喜欢 提交于 2019-11-27 11:57:07
问题 With reference to the android.arch.lifecycle.ViewModel class. ViewModel is scoped to the lifecycle of the UI component it relates to, so in a Fragment -based app, that will be the fragment lifecycle. This is a good thing. In some cases one wants to share a ViewModel instance between multiple fragments. Specifically I am interested in the case where many screens relate to the same underlying data . (The docs suggest similar approach when multiple related fragments are displayed on the same