How do I run code in the UI thread in an Android JUnit test without an Activity?

前端 未结 1 807
囚心锁ツ
囚心锁ツ 2021-02-02 17:34

I have a database component that relies on AsyncTask to retrieve data. Once used in the application it will always be called from the UI thread, but how do I do tha

1条回答
  •  迷失自我
    2021-02-02 18:35

    Android.OS.Handler should be able to update the ui.

    To use a handler you have to subclass it and overide handleMessage() to process messages

    Update:

    I am using monodroid, so I dont know if this is completely translatable, But,

    You may be able to use

    new Handler(context.getMainLooper()).post(runnable);
    

    0 讨论(0)
提交回复
热议问题