Java Code Examples for android.net.TrafficStats#setThreadStatsTag()
The following examples show how to use
android.net.TrafficStats#setThreadStatsTag() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GzipRequestInterceptor.java From mapbox-events-android with MIT License | 6 votes |
@Override public Response intercept(Interceptor.Chain chain) throws IOException { Request originalRequest = chain.request(); if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { return chain.proceed(originalRequest); } if (BuildConfig.DEBUG) { //Fix strict mode issue, see https://github.com/square/okhttp/issues/3537#issuecomment-431632176 TrafficStats.setThreadStatsTag(THREAD_ID); } Request compressedRequest = originalRequest.newBuilder() .header("Content-Encoding", "gzip") .method(originalRequest.method(), gzip(originalRequest.body())) .build(); return chain.proceed(compressedRequest); }
Example 2
Source File: NetworkDispatcher.java From SimplifyReader with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void addTrafficStatsTag(Request<?> request) { // Tag the request (if API >= 14) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { TrafficStats.setThreadStatsTag(request.getTrafficStatsTag()); } }
Example 3
Source File: NetworkDispatcher.java From okulus with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void addTrafficStatsTag(Request<?> request) { // Tag the request (if API >= 14) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { TrafficStats.setThreadStatsTag(request.getTrafficStatsTag()); } }
Example 4
Source File: FindFriendActivity.java From Expert-Android-Programming with MIT License | 5 votes |
private void followUser(int pos, boolean isFollowing) { if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) { try { TrafficStats.setThreadStatsTag(USER_INITIATED_REQUEST); // Once tag has been applied, network request has to be made request } finally { TrafficStats.clearThreadStatsTag(); } } User user = allList.get(pos); RetroInterface.getZomatoRestApi().followUser( SessionPreference.getUserId(context) + "", user.getId() + "", (isFollowing ? 1 : 0) + "", new Callback<NormalResponse>() { @Override public void success(NormalResponse userListResponse, Response response) { } @Override public void failure(RetrofitError error) { } } ); }
Example 5
Source File: NetworkDispatcher.java From TitanjumNote with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void addTrafficStatsTag(Request<?> request) { // Tag the request (if API >= 14) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { TrafficStats.setThreadStatsTag(request.getTrafficStatsTag()); } }
Example 6
Source File: NetworkDispatcher.java From SaveVolley with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void addTrafficStatsTag(Request<?> request) { // Tag the request (if API >= 14) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { TrafficStats.setThreadStatsTag(request.getTrafficStatsTag()); } }
Example 7
Source File: SignInBaseActivity.java From Expert-Android-Programming with MIT License | 5 votes |
private void goNormalLogin(User user) { if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) { try { TrafficStats.setThreadStatsTag(USER_INITIATED_REQUEST); // Once tag has been applied, network request has to be made request } finally { TrafficStats.clearThreadStatsTag(); } } RetroInterface.getZomatoRestApi().loginNormal( CommonFunctions.getHashMap(user), new Callback<UserResponse>() { @Override public void success(UserResponse userResponse, Response response) { if (userResponse != null && userResponse.isSuccess()) { if (userResponse.getUser() != null) { loginSuccess(userResponse.getUser()); } } } @Override public void failure(RetrofitError error) { } } ); }
Example 8
Source File: NetworkDispatcher.java From FeedListViewDemo with MIT License | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void addTrafficStatsTag(Request<?> request) { // Tag the request (if API >= 14) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { TrafficStats.setThreadStatsTag(request.getTrafficStatsTag()); } }
Example 9
Source File: RecentPlaceActivity.java From Expert-Android-Programming with MIT License | 5 votes |
private void getRecentlyViewed() { if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) { try { TrafficStats.setThreadStatsTag(APP_INITIATED_REQUEST); // Once tag has been applied, network request has to be made request } finally { TrafficStats.clearThreadStatsTag(); } } UserLocation location = LocationPreference.getUserLocation(context); RetroInterface.getZomatoRestApi().getRecentRestaurants( SessionPreference.getUserId(context) + "", location.getLatitude() + "", location.getLongitude() + "", new Callback<RestaurantResponse>() { @Override public void success(RestaurantResponse restaurantResponse, Response response) { if (restaurantResponse != null && restaurantResponse.isSuccess()) { allList = restaurantResponse.getItems(); allAdapter.refresh(allList); } } @Override public void failure(RetrofitError error) { } }); }
Example 10
Source File: NetworkDispatcher.java From product-emm with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void addTrafficStatsTag(Request<?> request) { // Tag the request (if API >= 14) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { TrafficStats.setThreadStatsTag(request.getTrafficStatsTag()); } }
Example 11
Source File: NetworkDispatcher.java From android-project-wo2b with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void addTrafficStatsTag(Request<?> request) { // Tag the request (if API >= 14) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { TrafficStats.setThreadStatsTag(request.getTrafficStatsTag()); } }
Example 12
Source File: NetworkDispatcher.java From pearl with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void addTrafficStatsTag(com.hanuor.pearl.volleysingleton.Request<?> request) { // Tag the request (if API >= 14) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { TrafficStats.setThreadStatsTag(request.getTrafficStatsTag()); } }
Example 13
Source File: NetworkDispatcher.java From volley with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void addTrafficStatsTag(Request<?> request) { // Tag the request (if API >= 14) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { TrafficStats.setThreadStatsTag(request.getTrafficStatsTag()); } }
Example 14
Source File: AddPlaceToCollectionActivity.java From Expert-Android-Programming with MIT License | 5 votes |
private void getRestaurantList() { if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) { try { TrafficStats.setThreadStatsTag(APP_INITIATED_REQUEST); // Once tag has been applied, network request has to be made request } finally { TrafficStats.clearThreadStatsTag(); } } UserLocation location = LocationPreference.getUserLocation(context); RetroInterface.getZomatoRestApi().getAllRestaurants( SessionPreference.getUserId(context) + "", location.getLatitude() + "", location.getLongitude() + "", new Callback<RestaurantResponse>() { @Override public void success(RestaurantResponse restaurantResponse, Response response) { if (restaurantResponse != null && restaurantResponse.isSuccess()) { allList = restaurantResponse.getItems(); //allAdapter.refresh(allList); refreshList(); } } @Override public void failure(RetrofitError error) { } } ); }
Example 15
Source File: ThreadTask.java From Aria with Apache License 2.0 | 5 votes |
@Override public ThreadTask call() throws Exception { isDestroy = false; Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); TrafficStats.setThreadStatsTag(UUID.randomUUID().toString().hashCode()); mAdapter.call(this); return this; }
Example 16
Source File: SearchPlaceActivity.java From Expert-Android-Programming with MIT License | 4 votes |
private void getUserLocationSearch() { if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) { try { TrafficStats.setThreadStatsTag(USER_INITIATED_REQUEST); // Once tag has been applied, network request has to be made request } finally { TrafficStats.clearThreadStatsTag(); } } UserLocation location = LocationPreference.getUserLocation(context); if (search != null && !search.equals("")) { if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) { try { TrafficStats.setThreadStatsTag(USER_INITIATED_REQUEST); // Once tag has been applied, network request has to be made request } finally { TrafficStats.clearThreadStatsTag(); } } RetroInterface.getZomatoRestApi().getSearchRestaurants( SessionPreference.getUserId(context) + "", search, location.getLatitude() + "", location.getLongitude() + "", new Callback<RestaurantResponse>() { @Override public void success(RestaurantResponse userLocationResponse, Response response) { if (userLocationResponse != null) { searchRestaurants = userLocationResponse.getItems(); searchRestaurantAdapter.refresh(searchRestaurants); if (searchRestaurants.size() != 0) { userHint.setText(""); } else { userHint.setText("No Users Found"); } } } @Override public void failure(RetrofitError error) { userHint.setText("No Users Found"); } } ); } }
Example 17
Source File: StrictModeHelloworldActivity.java From grpc-java with Apache License 2.0 | 4 votes |
@Override protected void beforeExecute(Thread t, Runnable r) { TrafficStats.setThreadStatsTag(trafficStatsTag); super.beforeExecute(t, r); }
Example 18
Source File: o.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public static void b(int i) { TrafficStats.setThreadStatsTag(i); }
Example 19
Source File: NetworkDispatcher.java From styT with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void addTrafficStatsTag(Request<?> request) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { TrafficStats.setThreadStatsTag(request.getTrafficStatsTag()); } }
Example 20
Source File: TrafficStatsCompatIcs.java From guideshow with MIT License | 4 votes |
public static void setThreadStatsTag(int tag) { TrafficStats.setThreadStatsTag(tag); }