2017-12-12 13 views
-2
내가 Thingspeak에서 데이터를 검색하는 모바일 앱을 개발하고

을에 표시되지 않으며, 나는 다음과 같은 형식의 JSON Object 응답을 얻을 수 있습니다구문 분석 JSON 응답은 텍스트 뷰

{ 
    "created_at": "2014-02-26T21:27:21Z", 
    "entry_id": 879455, 
    "field1": "176", 
    "field2": "28.195329087048833" 
} 

내가 무엇입니까를 logcat에 JSON 응답이 있지만 검색하려는 값이 내 앱의 TextView에 표시되지 않습니다. 다른 기기에서 코드를 시도했는데 (전에 Lollipop을 사용하기 전에 Lollipop 장치를 사용 했음) TextView에는 아무런 가치가 없었습니다. 젤리 빈 디바이스로부터

MainActivity.java

package com.example.teerna.testproject; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.os.AsyncTask; 
import android.util.Log; 
import android.widget.TextView; 
import org.json.JSONException; 
import org.json.JSONObject; 
import java.io.InputStream; 
import java.io.InputStreamReader; 
import java.net.HttpURLConnection; 
import java.net.URL; 
import java.net.MalformedURLException; 
import java.io.BufferedReader; 
import java.io.IOException; 

public class MainActivity extends AppCompatActivity { 
    TextView tv; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    tv =(TextView)findViewById(R.id.aTextView); 
    new GetMethodDemo().execute("https://api.thingspeak.com/channels/357670/feeds/last"); 

} 

public class GetMethodDemo extends AsyncTask<String , Void ,String> { 
    String server_response; 



    @Override 
    protected String doInBackground(String... strings) { 

     URL url; 
     HttpURLConnection urlConnection = null; 

     try { 
      url = new URL(strings[0]); 
      urlConnection = (HttpURLConnection) url.openConnection(); 

      int responseCode = urlConnection.getResponseCode(); 

      if(responseCode == HttpURLConnection.HTTP_OK){ 
       server_response = readStream(urlConnection.getInputStream()); 
       Log.v("CatalogClient", server_response); 
      } 

     } catch (MalformedURLException e) { 
      e.printStackTrace(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 

     return null; 
    } 

    // Converting InputStream to String 
    private String readStream(InputStream in) { 
     BufferedReader reader = null; 
     StringBuffer response = new StringBuffer(); 
     try { 
      reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); 
      String line = ""; 
      while ((line = reader.readLine()) != null) { 
       response.append(line); 
      } 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } finally { 
      if (reader != null) { 
       try { 
        reader.close(); 
       } catch (IOException e) { 
        e.printStackTrace(); 
       } 
      } 
     } 
     return response.toString(); 
    } 

    @Override 
    protected void onPostExecute(String response) { 
     super.onPostExecute(response); 

     if (response != null) { 
      //String item; 
      try { 
       JSONObject json = new JSONObject(response); 
       String item = json.optString("created_at"); 
       tv.setText(item); 

      } catch (JSONException j) { 
       j.printStackTrace(); 
      } 

     } 

     } 
    } 
} 

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
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:layout_height="match_parent" 
tools:context="com.example.teerna.testproject.MainActivity"> 

<TextView 
    android:id="@+id/aTextView" 
    android:layout_width="132dp" 
    android:layout_height="wrap_content" 
    app:layout_constraintBottom_toBottomOf="parent" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toTopOf="parent" /> 

</android.support.constraint.ConstraintLayout> 

로그 캣 :

01,232,293,722,849 : 사탕 장치로부터

12-12 12:04:17.762 15947-15947/? D/dalvikvm: Late-enabling CheckJNI 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.view.Window$Callback.onPointerCaptureChanged, referenced from method android.support.v7.view.WindowCallbackWrapper.onPointerCaptureChanged 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve interface method 15988: Landroid/view/Window$Callback;.onPointerCaptureChanged (Z)V 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve interface method 15990: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;) 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve interface method 15992: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve interface method 15996: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode; 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 704: Landroid/content/res/TypedArray;.getChangingConfigurations()I 
    12-12 12:04:19.164 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002 
    12-12 12:04:19.174 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType 
    12-12 12:04:19.174 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 726: Landroid/content/res/TypedArray;.getType (I)I 
    12-12 12:04:19.174 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0008 
    12-12 12:04:19.214 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.createDeviceProtectedStorageContext, referenced from method android.support.v4.content.ContextCompat.createDeviceProtectedStorageContext 
    12-12 12:04:19.214 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 485: Landroid/content/Context;.createDeviceProtectedStorageContext()Landroid/content/Context; 
    12-12 12:04:19.214 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.214 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.getCodeCacheDir, referenced from method android.support.v4.content.ContextCompat.getCodeCacheDir 
    12-12 12:04:19.214 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 491: Landroid/content/Context;.getCodeCacheDir()Ljava/io/File; 
    12-12 12:04:19.214 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.getColor, referenced from method android.support.v4.content.ContextCompat.getColor 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 492: Landroid/content/Context;.getColor (I)I 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v4.content.ContextCompat.getColorStateList 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 493: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList; 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.getDataDir, referenced from method android.support.v4.content.ContextCompat.getDataDir 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 495: Landroid/content/Context;.getDataDir()Ljava/io/File; 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.getDrawable, referenced from method android.support.v4.content.ContextCompat.getDrawable 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 496: Landroid/content/Context;.getDrawable (I)Landroid/graphics/drawable/Drawable; 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.getExternalCacheDirs, referenced from method android.support.v4.content.ContextCompat.getExternalCacheDirs 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 498: Landroid/content/Context;.getExternalCacheDirs()[Ljava/io/File; 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.getExternalFilesDirs, referenced from method android.support.v4.content.ContextCompat.getExternalFilesDirs 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 500: Landroid/content/Context;.getExternalFilesDirs (Ljava/lang/String;)[Ljava/io/File; 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.getNoBackupFilesDir, referenced from method android.support.v4.content.ContextCompat.getNoBackupFilesDir 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 503: Landroid/content/Context;.getNoBackupFilesDir()Ljava/io/File; 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.getObbDirs, referenced from method android.support.v4.content.ContextCompat.getObbDirs 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 505: Landroid/content/Context;.getObbDirs()[Ljava/io/File; 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.isDeviceProtectedStorage, referenced from method android.support.v4.content.ContextCompat.isDeviceProtectedStorage 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 516: Landroid/content/Context;.isDeviceProtectedStorage()Z 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.startForegroundService, referenced from method android.support.v4.content.ContextCompat.startForegroundService 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 531: Landroid/content/Context;.startForegroundService (Landroid/content/Intent;)Landroid/content/ComponentName; 
    12-12 12:04:19.224 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.334 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.widget.FrameLayout.startActionModeForChild, referenced from method android.support.v7.widget.ActionBarContainer.startActionModeForChild 
    12-12 12:04:19.334 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 16457: Landroid/widget/FrameLayout;.startActionModeForChild (Landroid/view/View;Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode; 
    12-12 12:04:19.334 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6f at 0x0002 
    12-12 12:04:19.344 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v7.content.res.AppCompatResources.getColorStateList 
    12-12 12:04:19.344 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 493: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList; 
    12-12 12:04:19.344 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 
    12-12 12:04:19.354 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/graphics/drawable/Icon;) 
    12-12 12:04:19.354 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.widget.ImageButton.setImageIcon, referenced from method android.support.v7.widget.AppCompatImageButton.setImageIcon 
    12-12 12:04:19.354 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 16480: Landroid/widget/ImageButton;.setImageIcon (Landroid/graphics/drawable/Icon;)V 
    12-12 12:04:19.354 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6f at 0x0000 
    12-12 12:04:19.354 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable 
    12-12 12:04:19.354 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 667: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable; 
    12-12 12:04:19.354 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002 
    12-12 12:04:19.354 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity 
    12-12 12:04:19.354 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 669: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable; 
    12-12 12:04:19.354 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002 
    12-12 12:04:19.464 15947-15947/com.example.teerna.testproject E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering 
    12-12 12:04:19.464 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve instanceof 193 (Landroid/graphics/drawable/RippleDrawable;) in Landroid/support/v7/widget/AppCompatImageHelper; 
    12-12 12:04:19.464 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x20 at 0x000c 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeMaxTextSize, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeMaxTextSize 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 16776: Landroid/widget/TextView;.getAutoSizeMaxTextSize()I 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeMinTextSize, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeMinTextSize 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 16777: Landroid/widget/TextView;.getAutoSizeMinTextSize()I 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeStepGranularity 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 16778: Landroid/widget/TextView;.getAutoSizeStepGranularity()I 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextAvailableSizes, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeTextAvailableSizes 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 16779: Landroid/widget/TextView;.getAutoSizeTextAvailableSizes()[I 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextType, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeTextType 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 16780: Landroid/widget/TextView;.getAutoSizeTextType()I 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6f at 0x0008 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithConfiguration, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithConfiguration 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 16823: Landroid/widget/TextView;.setAutoSizeTextTypeUniformWithConfiguration (IIII)V 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithPresetSizes, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithPresetSizes 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 16824: Landroid/widget/TextView;.setAutoSizeTextTypeUniformWithPresetSizes ([II)V 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeWithDefaults, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeWithDefaults 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 16825: Landroid/widget/TextView;.setAutoSizeTextTypeWithDefaults (I)V 
    12-12 12:04:19.484 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 
    12-12 12:04:19.534 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method android.support.v7.widget.AppCompatTextHelper.loadFromAttributes 
    12-12 12:04:19.534 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 16778: Landroid/widget/TextView;.getAutoSizeStepGranularity()I 
    12-12 12:04:19.534 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0197 
    12-12 12:04:19.534 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.text.StaticLayout$Builder.obtain, referenced from method android.support.v7.widget.AppCompatTextViewAutoSizeHelper.createStaticLayoutForMeasuring 
    12-12 12:04:19.534 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve static method 15266: Landroid/text/StaticLayout$Builder;.obtain (Ljava/lang/CharSequence;IILandroid/text/TextPaint;I)Landroid/text/StaticLayout$Builder; 
    12-12 12:04:19.534 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x71 at 0x0014 
    12-12 12:04:19.534 15947-15947/com.example.teerna.testproject I/dalvikvm: Could not find method android.widget.TextView.isInLayout, referenced from method android.support.v7.widget.AppCompatTextViewAutoSizeHelper.setRawTextSize 
    12-12 12:04:19.534 15947-15947/com.example.teerna.testproject W/dalvikvm: VFY: unable to resolve virtual method 16815: Landroid/widget/TextView;.isInLayout()Z 
    12-12 12:04:19.534 15947-15947/com.example.teerna.testproject D/dalvikvm: VFY: replacing opcode 0x6e at 0x0021 
    12-12 12:04:19.754 15947-15947/com.example.teerna.testproject D/libEGL: loaded /system/lib/egl/libGLES_java.so 

                      [ 12-12 12:04:19.764 15947:15947 D/   ] 
                      mem_init ++ 


                      [ 12-12 12:04:19.764 15947:15947 D/   ] 
                      gHwMemAllocator client 3 

                      [ 12-12 12:04:19.764 15947:15947 D/   ] 
                      **** Using ION allocator **** 


                      [ 12-12 12:04:19.764 15947:15947 D/   ] 
                      registered SIGUSR1[10] for pid[15947] 

                      [ 12-12 12:04:19.764 15947:15947 D/   ] 
                      HwMemAllocatorImpl Static Counters 0 0 


                      [ 12-12 12:04:19.764 15947:15947 D/   ] 
                      HwMemAllocatorImpl[5184cdcc] totalDeviceAllocSize[0] totalFree[0] maxFree[0] in numSlabs[0] 


                      [ 12-12 12:04:19.774 15947:15947 D/   ] 
                      mem_init 5184cdcc-- 
    12-12 12:04:19.774 15947-15947/com.example.teerna.testproject D/ION: config: version(0x10000) secure(0xf000) 256M(0x22d) fast(0x608) hwwr(0x608) 
    12-12 12:04:19.784 15947-15947/com.example.teerna.testproject D/MM_DEVICE: Waiting for mm thread to come up 
    12-12 12:04:19.784 15947-15965/com.example.teerna.testproject D/MM_DEVICE: mm_device_thread starting 
    12-12 12:04:19.814 15947-15947/com.example.teerna.testproject D/OpenGLRenderer: Enabling debug mode 0 
    12-12 12:04:23.067 15947-15964/com.example.teerna.testproject V/CatalogClient: {"created_at":"2017-12-02T09:37:26Z","entry_id":39,"field1":"6519"} 

로그 캣

앱이 실행될 때 두 기기 모두 동일한 화면을 표시합니다 (TextView에는 값이 검색되지 않음).

+5

반환'대신 그 일을 :) 감사 @Emil null'' – Emil

+0

''의 doInBackGround''''에서'server_response'' : D – Tia

답변

0

null을 반환하면 server_responsedoInBackGround(String... strings)에서 반환하십시오.

public class GetMethodDemo extends AsyncTask<String , Void ,String> { 
    String server_response; 

    @Override 
    protected String doInBackground(String... strings) { 

     URL url; 
     HttpURLConnection urlConnection = null; 

     try { 
      url = new URL(strings[0]); 
      urlConnection = (HttpURLConnection) url.openConnection(); 

      int responseCode = urlConnection.getResponseCode(); 

      if(responseCode == HttpURLConnection.HTTP_OK){ 
       server_response = readStream(urlConnection.getInputStream()); 
       Log.v("CatalogClient", server_response); 
      } 

     } catch (MalformedURLException e) { 
      e.printStackTrace(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 

     return server_response; //this should return server_response 
    } 

    // Converting InputStream to String 
    private String readStream(InputStream in) { 
     BufferedReader reader = null; 
     StringBuffer response = new StringBuffer(); 
     try { 
      reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); 
      String line = ""; 
      while ((line = reader.readLine()) != null) { 
       response.append(line); 
      } 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } finally { 
      if (reader != null) { 
       try { 
        reader.close(); 
       } catch (IOException e) { 
        e.printStackTrace(); 
       } 
      } 
     } 
     return response.toString(); 
    } 

    @Override 
    protected void onPostExecute(String response) { 
     super.onPostExecute(response); 

     if (response != null) { 
      //String item; 
      try { 
       JSONObject json = new JSONObject(response); 
       String item = json.optString("created_at"); 
       tv.setText(item); 

      } catch (JSONException j) { 
       j.printStackTrace(); 
      } 

     } 

     } 
    }