Chuyển đến nội dung chính

Bài đăng

Đang hiển thị bài đăng từ Tháng 4, 2020

Các cách sử dụng progressbar (có cách tạo 1 progressbar sử dụng nhiều layout)

Handling ProgressBars Edit Page Page History Overview https://guides.codepath.com/android/handling-progressbars ProgressBar is used to display the progress of an activity while the user is waiting. You can display an  indeterminate  progress (spinning wheel) or  result-based  progress. Indeterminate We can display an indeterminate progress bar which we show to indicate waiting: <ProgressBar android:id= "@+id/pbLoading" android:visibility= "invisible" android:layout_width= "wrap_content" android:layout_height= "wrap_content" /> and then manage the visibility in the activity: // on some click or some loading we need to wait for... ProgressBar pb = ( ProgressBar ) findViewById ( R . id . pbLoading ); pb . setVisibility ( ProgressBar . VISIBLE ); // run a background job and once complete pb . setVisibility ( ProgressBar . INVISIBLE ); Typically you want to try to put the  ProgressBar  in the place whe...

Cách bắt sư kiện onTaskRemoved (xóa ứng dụng ra khỏi list các ứng dụng được mở gần nhất)

Tạo 1 Serive public class OnClearFromRecentService extends Service { public OnClearFromRecentService () { } @Override public IBinder onBind (Intent intent) { // TODO: Return the communication channel to the service. throw new UnsupportedOperationException( "Not yet implemented" ) ; } @Override public void onTaskRemoved (Intent rootIntent) { super .onTaskRemoved(rootIntent) ; // TODO: Code cần làm khi sự kiên TaskRemoved xảy ra } } Vào file AndroidManifest.xml thêm dòng vào giữa thẻ  <application  và  </application> <service android :name =".AppService.OnClearFromRecentService" android :stopWithTask ="false" ></service> Vào Activity SplashScreenActivity (Activity được gọi đầu tiên của ứng dụng) thêm dòng startService( new Intent(getBaseContext() , OnClearFromRecentService. class )) ;

Cách sử dụng @path và @query trong Retrofit

Consider this is the url: www.app.net/api/searchtypes/862189/filters?Type=6&SearchText=School Now this is the call: @GET ( "/api/searchtypes/{Id}/filters" ) Call < FilterResponse > getFilterList ( @Path ( "Id" ) long customerId , @Query ( "Type" ) String responseType , @Query ( "SearchText" ) String searchText ); So we have: www . app . net / api / searchtypes /{ Path }/ filters ? Type ={ Query }& SearchText ={ Query }

Working with MVP and Retrofit 2.0 in Android

https://medium.com/@shri_chaudhari/working-with-mvp-and-retrofit-2-0-in-android-4016253ab3fc Recently I have observed that many Android developers are talking about the app architecture, usage of new libraries in the project. So I was thinking why not create a post which will cover some of the topics, so I have decided to go with MVP along with Retrofit 2.0. This post is what I have researched and learnt from various resources. You can even find an example for the same in this blog. I believe that many of you are already aware of MVP and Retrofit, so without going into much details, I will give short descriptions and then start with the example. MVP (Model-View-Presenter) The MVP stands for Model View Presenter. In this architecture, each layer is defined to do certain tasks. Fig 1. MVP Architecture Model  is responsible for handling all business logic, communication with backend server and database operations. The  View  is responsible for dis...