android

HTTP FAILED: java.io.IOException: unexpected end of stream exception while making https request

好久不见. 提交于 2021-02-16 20:05:02
问题 We are previously using http apis and now we have migrated to https, with same code we are facing the exception HTTP FAILED: java.io.IOException: unexpected end of stream (this is for some device and for some network calls). We are using the OkHttp and Retrofit from android app. Below is our code @Provides @ApplicationScope OkHttpClient provideOkHttpClientV2( HttpLoggingInterceptor logging, Interceptor headerInterceptor) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); //Removed

HTTP FAILED: java.io.IOException: unexpected end of stream exception while making https request

て烟熏妆下的殇ゞ 提交于 2021-02-16 20:04:23
问题 We are previously using http apis and now we have migrated to https, with same code we are facing the exception HTTP FAILED: java.io.IOException: unexpected end of stream (this is for some device and for some network calls). We are using the OkHttp and Retrofit from android app. Below is our code @Provides @ApplicationScope OkHttpClient provideOkHttpClientV2( HttpLoggingInterceptor logging, Interceptor headerInterceptor) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); //Removed

android EditText highlight multiple words in the text

大城市里の小女人 提交于 2021-02-16 19:18:06
问题 I have searched some words in the text of a EditText. After some logic, I get the index of these words. The indices are stored in an arrayList>. Then I used this function to highlight the color of these words. public void changeColor(EditText et, ArrayList<ArrayList<Integer>> arr) { Spannable wordtoSpan = new SpannableString(et.getText()); if (arr==null) return; for (int i=0; i<arr.size(); i++){ wordtoSpan.setSpan(new BackgroundColorSpan(Color.BLUE), arr.get(i).get(0), arr.get(i).get(1),

CollapsingToolbarLayout cannot be cast to android.support.v7.widget.Toolbar

坚强是说给别人听的谎言 提交于 2021-02-16 19:03:11
问题 Working on this Collapsing Toolbar layout everything works fine but the moment I add code in the java class Main activity, error shows up and app crashes. Without java code it was working properly. XML: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android

android - how to have a clickable AND checkable textview

不想你离开。 提交于 2021-02-16 18:58:26
问题 I want to have the following: a textview that .)changes its background when clicked .)maintains that background until it is clicked again it all comes down to the "checkable" state, but i couldnt figure out how this exactly works. here is the xml i am using for background: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- pressed --> <item android:drawable="@drawable/menuselected" android:state_pressed="true" /> <!-- checked -->

Could not find com.android.tools.build:gradle:3.3.0.

天大地大妈咪最大 提交于 2021-02-16 18:43:57
导入新项目时报错: Error:Could not find com.android.tools.build:gradle:3.3.0. Searched in the following locations: file:/F:/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.3.0/gradle-3.0.0.pom file:/F:/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.3.0/gradle-3.0.0.jar https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.0/gradle-3.0.0.pom https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.0/gradle-3.3.0.jar Required by: project : 解决办法: 在repositories{}内添加google() 它会去更换为 https://dl.google.com/ 下载 buildscript { repositories {

How to display the exact number of items from a Firebase Database in a ListView using FirebaseListAdapter with Android?

不羁岁月 提交于 2021-02-16 18:27:06
问题 I have a very simple Firebase Database which looks like this: This is my model: public class ShoppingListModel { private String shoppingListName; private Map<String, String> usersMap; public ShoppingListModel() {} public void setShoppingListName(String shoppingListName) {this.shoppingListName = shoppingListName;} public String getShoppingListName() {return shoppingListName;} public void setUsersMap(Map<String, String> usersMap) {this.usersMap = usersMap;} public Map<String, String>

How to filter logcat to remove irrelevant statements

风流意气都作罢 提交于 2021-02-16 18:22:45
问题 I'm new to Android Studio, using latest version, and trying to code a basic calculator app. For some reason, my logcat is full of 2021-01-11 14:38:35.288 6938-6938/? W/cmd: Can't find service car_service This is really annoying for debugging. How can I get rid of it ? 回答1: I'll change my comment to an answer, seeing as though it actually helped: click on logcat at the bottom of android studio, then (i'm assuming) yours will show no filters , change that dropdown to show only selected

how to store recyclerview data on onSaveInstanceState

拥有回忆 提交于 2021-02-16 18:21:06
问题 I want to save data from the API in the RecyclerView so that when rotating the screen is not reloaded I think I can use onSaveInstanceState but still don't really understand how to use it @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final RecyclerView rvTVShow = view.findViewById(R.id.rv_shows); rvTVShow.setHasFixedSize(true); rvTVShow.setLayoutManager(new LinearLayoutManager(getActivity()));

JSONException: No value for id

核能气质少年 提交于 2021-02-16 18:18:27
问题 It reads and writes fine from the database but gives the JSONException error. Any help would be greatly appreciated! Thank you 回答1: This error happens in getter functions of a JSONObject and it means that you are trying to retrieve a value from the JSONObject using an id that doesn't exist in the JSONObject. Before retrieving a value, check if it actually exists in the JSONObject by the has(String name) method or using the opt methods. For more information about the JSONObject class see here.