Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Internet of Things IoT Frameworks 2 years ago
* If placeholders are disabled, onBind will never receive null but as more pages are * loaded, the scrollbars will jitter as new pages are loaded. You should probably disable * scrollbars if you disable placeholders. */ private const val ENABLE_PLACEHOLDERS = true } val allBookmarks = LivePagedListBuilder(dao.allBookmarkByDatetime(), PagedList.Config.Builder() .setPageSize(PAGE_SIZE) .setEnablePlaceholders(ENABLE_PLACEHOLDERS) .build()).build() fun insert(title: String, description: String, datetime: String) = ioThread { dao.insert(Bookmark(id = 0, title = title, description = description, datetime = datetime)) } fun remove(bookmark: Bookmark) = ioThread { dao.delete(bookmark) } } This is from the google samples.. After I want to: class BookmarkListFragment : FirstFragment() { private var viewModel: BookmarkViewModel? = null .. override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) viewModel = ViewModelProviders.of(activity!!).get(BookmarkViewModel::class.java) ... And here is the problem: java.lang.RuntimeException: Cannot create an instance of class com.lacas.db.room.BookmarkViewModel Can I use this in a fragment? java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lacas.asd/com.lacas.asd.ui.activities.testtabs.TestTab2Activity}: java.lang.RuntimeException: Cannot create an instance of class com.lacas.asd.db.room.BookmarkViewModel at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2924) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6692) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358) Caused by: java.lang.RuntimeException: Cannot create an instance of class com.lacas.asd.db.room.BookmarkViewModel at android.arch.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:207) at android.arch.lifecycle.ViewModelProvider.get(ViewModelProvider.java:134) at android.arch.lifecycle.ViewModelProvider.get(ViewModelProvider.java:102) at com.lacas.asd.ui.activities.testtabs.TestTab2Activity$viewModel$2.invoke(TestTab2Activity.kt:34) at com.lacas.asd.ui.activities.testtabs.TestTab2Activity$viewModel$2.invoke(TestTab2Activity.kt:29) at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:154) at com.lacas.asd.ui.activities.testtabs.TestTab2Activity.getViewModel(TestTab2Activity.kt) at com.lacas.asd.ui.activities.testtabs.TestTab2Activity.onCreated(TestTab2Activity.kt:45) at com.lacas.asd.base.BasePermissionsActivity.onCreate(BasePermissionsActivity.kt:34) at android.app.Activity.performCreate(Activity.java:6912) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2877) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)Â at android.app.ActivityThread.-wrap14(ActivityThread.java)Â at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)Â at android.os.Handler.dispatchMessage(Handler.java:102)Â at android.os.Looper.loop(Looper.java:154)Â at android.app.ActivityThread.main(ActivityThread.java:6692)Â at java.lang.reflect.Method.invoke(Native Method)Â at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)Â at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)Â Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:430) at android.arch.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:199) at android.arch.lifecycle.ViewModelProvider.get(ViewModelProvider.java:134)Â at android.arch.lifecycle.ViewModelProvider.get(ViewModelProvider.java:102)Â at com.lacas.asd.ui.activities.testtabs.TestTab2Activity$viewModel$2.invoke(TestTab2Activity.kt:34)Â at com.lacas.asd.ui.activities.testtabs.TestTab2Activity$viewModel$2.invoke(TestTab2Activity.kt:29)Â at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:154)Â at com.lacas.asd.ui.activities.testtabs.TestTab2Activity.getViewModel(TestTab2Activity.kt)Â at com.lacas.asd.ui.activities.testtabs.TestTab2Activity.onCreated(TestTab2Activity.kt:45)Â at com.lacas.asd.base.BasePermissionsActivity.onCreate(BasePermissionsActivity.kt:34)Â at android.app.Activity.performCreate(Activity.java:6912)Â at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)Â at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2877)Â at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)Â at android.app.ActivityThread.-wrap14(ActivityThread.java)Â at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)Â at android.os.Handler.dispatchMessage(Handler.java:102)Â at android.os.Looper.loop(Looper.java:154)Â at android.app.ActivityThread.main(ActivityThread.java:6692)Â at java.lang.reflect.Method.invoke(Native Method)Â at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)Â at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)Â Caused by: java.lang.RuntimeException: cannot find implementation for com.lacas.asd.db.room.BookmarkDb. BookmarkDb_Impl does not exist at android.arch.persistence.room.Room.getGeneratedImplementation(Room.java:93) at android.arch.persistence.room.RoomDatabase$Builder.build(RoomDatabase.java:630) at com.lacas.asd.db.room.BookmarkDb$Companion.get(BookmarkDb.kt:29) at com.lacas.asd.db.room.BookmarkViewModel.(BookmarkViewModel.kt:14) at java.lang.reflect.Constructor.newInstance0(Native Method)Â at java.lang.reflect.Constructor.newInstance(Constructor.java:430)Â at android.arch.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:199)Â at android.arch.lifecycle.ViewModelProvider.get(ViewModelProvider.java:134)Â at android.arch.lifecycle.ViewModelProvider.get(ViewModelProvider.java:102)Â at com.lacas.asd.ui.activities.testtabs.TestTab2Activity$viewModel$2.invoke(TestTab2Activity.kt:34)Â at com.lacas.asd.ui.activities.testtabs.TestTab2Activity$viewModel$2.invoke(TestTab2Activity.kt:29)Â at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:154)Â at com.lacas.asd.ui.activities.testtabs.TestTab2Activity.getViewModel(TestTab2Activity.kt)Â at com.lacas.asd.ui.activities.testtabs.TestTab2Activity.onCreated(TestTab2Activity.kt:45)Â at com.lacas.asd.base.BasePermissionsActivity.onCreate(BasePermissionsActivity.kt:34)Â at android.app.Activity.performCreate(Activity.java:6912)Â at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)Â at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2877)Â at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)Â at android.app.ActivityThread.-wrap14(ActivityThread.java)Â at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)Â at android.os.Handler.dispatchMessage(Handler.java:102)Â at android.os.Looper.loop(Looper.java:154)Â at android.app.ActivityThread.main(ActivityThread.java:6692)Â at java.lang.reflect.Method.invoke(Native Method)Â at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)Â at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)Â
Posted on 16 Aug 2022, this text provides information on IoT Frameworks related to Internet of Things. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Internet of Things 0 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.