android-jetpack

Setting target resolution for CameraX not working as in documentation

旧街凉风 提交于 2019-12-20 03:29:18
问题 I want to capture photos with fixed resolution (i.e. 1200x1600 ) using CameraX library. So according to documentation I can set target resolution for ImageCaptureConfig : val imageCaptureConfig = ImageCaptureConfig.Builder() .setLensFacing(CameraX.LensFacing.BACK) .setCaptureMode(ImageCapture.CaptureMode.MAX_QUALITY) .setTargetResolution(Size(1200, 1600)) .setTargetAspectRatio(Rational(3,4)) .build() Documentation describes setTargetResolution method as follows: Sets the intended output

Periodic daily work requests using WorkManager

我是研究僧i 提交于 2019-12-18 20:47:15
问题 How to properly use the new WorkManager from Android Jetpack to schedule a one per day periodic work that should do some action on a daily basis and exactly one time? The idea was to check if the work with a given tag already exists using WorkManager and to start a new periodic work otherwise. I've tried to do it using next approach: public static final String CALL_INFO_WORKER = "Call worker"; ... WorkManager workManager = WorkManager.getInstance(); List<WorkStatus> value = workManager

Navigation Architecture Component - Dialog Fragments

孤街浪徒 提交于 2019-12-18 12:07:33
问题 Is it possible to use the new Navigation Architecture Component with DialogFragment? Do I have to create a custom Navigator? I would love to use them with the new features in my navigation graph. 回答1: No, as of the 1.0.0-alpha01 build, there is no support for dialogs as part of your Navigation Graph. You should just continue to use show() to show a DialogFragment . 回答2: May 2019 Update : DialogFragment are now fully supported starting from Navigation 2.1.0-alpha03 , you can read more here and

Android JetPack navigation with multiple stack

隐身守侯 提交于 2019-12-18 11:19:09
问题 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

Dynamic ActionBar title from a Fragment using AndroidX Navigation

孤街醉人 提交于 2019-12-18 11:04:31
问题 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

Android Jetpack Navigation with ViewPager and TabLayout

对着背影说爱祢 提交于 2019-12-18 10:42:54
问题 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

How to share an instance of LiveData in android app?

南楼画角 提交于 2019-12-17 21:16:34
问题 Simple use case I am using MVVM architecture and Android Architecture Components in my app. After user logs in, I am fetching multiple network data and want to have access to it from different ViewModels attached to different Activities lifecycle. I don't want to use Room Persistence Library in my app. I have seen some question about sharing a ViewModel between Activities or using a LiveData as static member, but I think most of the cases we need to access the same data in multiple screens. I

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

≯℡__Kan透↙ 提交于 2019-12-17 15:43:05
问题 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

can I always use WorkManager instead of coroutines?

心不动则不痛 提交于 2019-12-13 12:08:47
问题 I wonder why should I bother with rx or coroutines when there is brilliant solution as WorkManager. But for almost all tutorials they use coroutines so may be WorkManager has disadvantages ? 回答1: The scope of both is different. WorkManager is to schedule deferrable (for any later time) or immediately. tasks asynchronously. As documentation says The WorkManager API makes it easy to specify deferrable, asynchronous tasks and when they should run. These APIs let you create a task and hand it off

Android paging library + Firestore crashes with IllegalStateException

折月煮酒 提交于 2019-12-13 04:01:19
问题 I trying to implement the new Android paging library using Firestore as my backend. I have created a class MyDataSource that extends PageKeyedDataSource<Integer, MyObject> , where I'm implementing three functions: loadInitial loadBefore loadAfter For example one of the functions is this: @Override public void loadInitial(@NonNull LoadInitialParams<Integer> params, @NonNull final LoadInitialCallback<Integer, MyObject> callback) { query.addSnapshotListener((snapshots, exception) -> { if