mình thấy defer = true | false thì nó đều chạy hàm register à bạn
Tại sao bạn lại thấy như vậy Cụ thể bạn đã làm những gì để ra kết quả đó?
Mà trong bài viết mình đề cập việc set $defer là true thì service sẽ được load khi nó lần đầu tiên được gọi đến, và lúc này hàm register sẽ được chạy mà, chứ ý mình không phải là set $defer = true thì hàm register sẽ mãi mãi không được chạy.
Bạn có thể tìm hiểu thêm về Deferred Providers trên Document của Laravel, trên đó có nói rõ:
If your provider is only registering bindings in the service container, you may choose to defer its registration until one of the registered bindings is actually needed. Deferring the loading of such a provider will improve the performance of your application, since it is not loaded from the filesystem on every request.
Laravel compiles and stores a list of all of the services supplied by deferred service providers, along with the name of its service provider class. Then, only when you attempt to resolve one of these services does Laravel load the service provider.
To defer the loading of a provider, set the defer property to true and define a provides method. The provides method should return the service container bindings registered by the provider
Ngoài ra, bạn cũng có thể xem thêm về code của Framework để kiểm tra cách nó load deferred providers, cụ thể là ở file laravel/framework/src/Illuminate/Foundation/Application.php.
private void getDeviceLocation() {
/*
* Get the best and most recent location of the device, which may be null in rare
* cases when a location is not available.
*/
try {
if (mLocationPermissionGranted) {
Task locationResult = mFusedLocationProviderClient.getLastLocation();
locationResult.addOnCompleteListener(this, new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if (task.isSuccessful()) {
// Set the map's camera position to the current location of the device.
mLastKnownLocation = task.getResult();
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(mLastKnownLocation.getLatitude(),
mLastKnownLocation.getLongitude()), DEFAULT_ZOOM));
} else {
Log.d(TAG, "Current location is null. Using defaults.");
Log.e(TAG, "Exception: %s", task.getException());
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mDefaultLocation, DEFAULT_ZOOM));
mMap.getUiSettings().setMyLocationButtonEnabled(false);
}
}
});
}
} catch(SecurityException e) {
Log.e("Exception: %s", e.getMessage());
}
}
The My Location layer provides a simple way to display a device's location on the map. It does not provide data. (My Location layer cung cấp một cách đơn giản để hiển thị vị trí của thiết bị trên map, chứ nó không cung cấp dữ liệu location)
The Google Play services Location API is recommended for all programmatic requests for location data. (The Google Play services Location API được khuyến nghị cho mọi yêu cầu về dữ liệu location).
Bài viết Android location API using Google Play services của mình là nói về ý thứ 2 nên không liên quan gì tới map cả. Còn câu hỏi của bạn theo như mình hiểu thì là làm sao hiển thị nút vị trí hiện tại trên map? Với câu hỏi này thì bạn có thể tham khảo bài viết sau về google map https://viblo.asia/p/bat-dau-voi-google-maps-api-cho-android-DzVkpoZPenW. Sau khi hiển thị được map thì bạn chỉ cần thêm dòng mGoogleMap.setMyLocationEnabled(true); vào trong hàm onMapReady là có thể hiển thị button my location.
Nếu có vấn đề gì thì bạn cứ lên đây trao đổi tiếp nhé .
thầy ơi cho em hỏi là muốn hiển thị nút vị trí hiện tại bằng gps như của google hướng dẫn thì như thế này https://developers.google.com/maps/documentation/android-api/location?hl=vi#my-location
em làm theo mà không được, đọc bài của thầy nhưng dài quá , có thể sử dụng nhưng google hướng dẫn được không ạ, em làm mà không hề hiển thị nút vị trí hiện tại ạ. mong thầy giải đáp em cảm ơn
THẢO LUẬN
Bài viết rất hay. Cảm ơn chủ thớt nhiều!
ồ dạ vâng em cảm ơn ạ
.
Tại sao bạn lại thấy như vậy
Cụ thể bạn đã làm những gì để ra kết quả đó?
Mà trong bài viết mình đề cập việc set
$deferlàtruethì service sẽ được load khi nó lần đầu tiên được gọi đến, và lúc này hàmregistersẽ được chạy mà, chứ ý mình không phải là set$defer = truethì hàmregistersẽ mãi mãi không được chạy.Bạn có thể tìm hiểu thêm về Deferred Providers trên Document của Laravel, trên đó có nói rõ:
Ngoài ra, bạn cũng có thể xem thêm về code của Framework để kiểm tra cách nó load
deferred providers, cụ thể là ở filelaravel/framework/src/Illuminate/Foundation/Application.php.các biến đó thì mình phải tạo thôi, trên tutorial có phần Get the Code https://developers.google.com/maps/documentation/android-api/current-place-tutorial#get-the-code do hơi dài nên Google đã cho Hide đi, bạn ấn Show là sẽ thây đầy đủ code hoặc clone từ repo google-map-sample của Google https://github.com/googlemaps/android-samples
Dữ liệu luôn là vô giá, không nên xóa cứng với bất kỳ lý do gì, nhất là trên prod
do mới tìm hiểu cả android nữa nên hơi khó hiểu á thầy thế cá biến "mLocationPermissionGranted" "mDefaultLocation","mLastKnownLocation","mLastKnownLocation" lấy ở đâu ra ạ, em có hơi chậm hiểu phầm đọc tài liệu á thầy
https://developers.google.com/maps/documentation/android-api/current-place-tutorial
private void getDeviceLocation() { /* * Get the best and most recent location of the device, which may be null in rare * cases when a location is not available. */ try { if (mLocationPermissionGranted) { Task locationResult = mFusedLocationProviderClient.getLastLocation(); locationResult.addOnCompleteListener(this, new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if (task.isSuccessful()) { // Set the map's camera position to the current location of the device. mLastKnownLocation = task.getResult(); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom( new LatLng(mLastKnownLocation.getLatitude(), mLastKnownLocation.getLongitude()), DEFAULT_ZOOM)); } else { Log.d(TAG, "Current location is null. Using defaults."); Log.e(TAG, "Exception: %s", task.getException()); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mDefaultLocation, DEFAULT_ZOOM)); mMap.getUiSettings().setMyLocationButtonEnabled(false); } } }); } } catch(SecurityException e) { Log.e("Exception: %s", e.getMessage()); } }
Trước hết mình cần làm rõ vấn đề như sau trích từ https://developers.google.com/maps/documentation/android-api/location?hl=vi#working_with_location_data
Bài viết Android location API using Google Play services của mình là nói về ý thứ 2 nên không liên quan gì tới map cả. Còn câu hỏi của bạn theo như mình hiểu thì là làm sao hiển thị nút vị trí hiện tại trên map? Với câu hỏi này thì bạn có thể tham khảo bài viết sau về google map https://viblo.asia/p/bat-dau-voi-google-maps-api-cho-android-DzVkpoZPenW. Sau khi hiển thị được map thì bạn chỉ cần thêm dòng mGoogleMap.setMyLocationEnabled(true); vào trong hàm onMapReady là có thể hiển thị button my location.
Nếu có vấn đề gì thì bạn cứ lên đây trao đổi tiếp nhé
.
(good) 5sao nhé anh (lol)
Nếu $defer là true thì không chạy hàm register. mình thấy $defer = true | false thì nó đều chạy hàm register à bạn
thầy ơi cho em hỏi là muốn hiển thị nút vị trí hiện tại bằng gps như của google hướng dẫn thì như thế này https://developers.google.com/maps/documentation/android-api/location?hl=vi#my-location em làm theo mà không được, đọc bài của thầy nhưng dài quá , có thể sử dụng nhưng google hướng dẫn được không ạ, em làm mà không hề hiển thị nút vị trí hiện tại ạ. mong thầy giải đáp em cảm ơn
Thanks!
Xin chào, bạn cho mình xin facebook hoặc zalo nhé, mình cần nhờ bạn giúp một chút
rất hữu ích
với multi target thì khai báo ra sao ạ?
Add chơi chữ quá, giấu hàm open
@nguyenduong96
Anh thử tải PHPStorm về chạy trên máy mình cùng không có mục
Chắc phiên bản người ta dùng là phiên bản khác 
composerở context menuVấn đề 1: Em đã nâng cấp phiên bản MacOS lên 10.13, nâng php lên 7, cài thêm brew, wget nữa và giờ đã thành công. https://scontent.fsgn5-1.fna.fbcdn.net/v/t34.0-12/22447205_1108733289261660_2016444917_n.png?oh=5944f7a09daefb4a63f8fb614793d3ce&oe=59E038FD
Vấn đề 2: Đã xong luôn.
Vấn đề 3: Ý em là muốn hiện lên mục composer khi mình chuột phải vào dự án thôi, chứ em biết nó có trên phần tool rồi.
Just use https://docs.python.org/3/tutorial/index.html
Dạ em cảm ơn anh nhiều ạ
Cho mình hỏi làm sao exit() trương trình (thoát khỏi vòng lặp while Cussumer) trong vd về Condition with thread. Thanks,