2016-12-26 33 views
0

データベースから画像をフェッチして画像ビューに表示するためにMySQLサーバーを使用しています。しかし、私は、次のエラーが表示さ:SkImageDecoder:工場出荷時にnullが返されました

SkImageDecoder:: Factory returned null 

をこれは前に回答されているが、私は一度.decodeStreamを呼びますか?固定

12-25 22:01:30.150 30009-30009/com.example.ayush.testingfordata  I/ViewRootImpl: ViewRoot's Touch Event : Touch Down 
12-25 22:01:30.180 30009-30009/com.example.ayush.testingfordata I/ViewRootImpl: ViewRoot's Touch Event : Touch UP 
12-25 22:01:30.340 30009-30225/com.example.ayush.testingfordata D/libc: getaddrinfo called from pid =30009 
12-25 22:01:30.340 30009-30225/com.example.ayush.testingfordata E/DataScheduler: isDataSchedulerEnabled():false 
12-25 22:01:30.340 30009-30225/com.example.ayush.testingfordata D/libc: getaddrinfo called from pid =30009 
12-25 22:01:31.080 30009-30225/com.example.ayush.testingfordata D/libc: dnsproxy getaddrinfo returns 0 
12-25 22:01:31.800 30009-30282/com.example.ayush.testingfordata D/skia: --- SkImageDecoder::Factory returned null 
+0

私は決して気にせず、PHPスクリプトではエラーでした。 –

答えて

-1

、PHPスクリプトとデータベース中のエラー:あなたが

MainActivty.java

public class MainActivity extends AppCompatActivity implements View.OnClickListener { 
private String imagesJSON; 

private static final String JSON_ARRAY ="result"; 
private static final String IMAGE_URL = "url"; 

private JSONArray arrayImages= null; 

private int TRACK = 0; 

private static final String IMAGES_URL = "http://thakurnigamananda.com/getAllImages.php"; 

private Button buttonFetchImages; 
private Button buttonMoveNext; 
private Button buttonMovePrevious; 
private ImageView imageView; 


@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    imageView = (ImageView) findViewById(R.id.imageView); 
    buttonFetchImages = (Button) findViewById(R.id.buttonFetchImages); 
    buttonMoveNext = (Button) findViewById(R.id.buttonNext); 
    buttonMovePrevious = (Button) findViewById(R.id.buttonPrev); 
    buttonFetchImages.setOnClickListener(this); 
    buttonMoveNext.setOnClickListener(this); 
    buttonMovePrevious.setOnClickListener(this); 
} 


private void extractJSON(){ 
    try { 
     JSONObject jsonObject = new JSONObject(imagesJSON); 
     arrayImages = jsonObject.getJSONArray(JSON_ARRAY); 
    } catch (JSONException e) { 
     e.printStackTrace(); 
    } 
} 

private void showImage(){ 
    try { 
     JSONObject jsonObject = arrayImages.getJSONObject(TRACK); 
     getImage(jsonObject.getString(IMAGE_URL)); 
    } catch (JSONException e) { 
     e.printStackTrace(); 
    } 
} 

private void moveNext(){ 
    if(TRACK < arrayImages.length()){ 
     TRACK++; 
     showImage(); 
    } 
} 

private void movePrevious(){ 
    if(TRACK>0){ 
     TRACK--; 
     showImage(); 
    } 
} 



private void getAllImages() { 
    class GetAllImages extends AsyncTask<String,Void,String>{ 
     ProgressDialog loading; 
     @Override 
     protected void onPreExecute() { 
      super.onPreExecute(); 
      loading = ProgressDialog.show(MainActivity.this, "Fetching Data...","Please Wait...",true,true); 
     } 

     @Override 
     protected void onPostExecute(String s) { 
      super.onPostExecute(s); 
      loading.dismiss(); 
      imagesJSON = s; 
      extractJSON(); 
      showImage(); 
     } 

     @Override 
     protected String doInBackground(String... params) { 
      String uri = params[0]; 
      BufferedReader bufferedReader = null; 
      try { 
       URL url = new URL(uri); 
       HttpURLConnection con = (HttpURLConnection) url.openConnection(); 
       StringBuilder sb = new StringBuilder(); 

       bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream())); 
       String json; 
       while((json = bufferedReader.readLine())!= null){ 
        sb.append(json+"\n"); 
       } 

       return sb.toString().trim(); 

      }catch(Exception e){ 
       return null; 
      } 
     } 
    } 
    GetAllImages gai = new GetAllImages(); 
    gai.execute(IMAGES_URL); 
} 

private void getImage(String urlToImage){ 
    class GetImage extends AsyncTask<String,Void,Bitmap>{ 
     ProgressDialog loading; 
     @Override 
     protected Bitmap doInBackground(String... params) { 
      URL url = null; 
      Bitmap image = null; 

      String urlToImage = params[0]; 
      try { 
       url = new URL(urlToImage); 
       image = BitmapFactory.decodeStream(url.openConnection().getInputStream()); 

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

     @Override 
     protected void onPreExecute() { 
      super.onPreExecute(); 
      loading = ProgressDialog.show(MainActivity.this,"Downloading Image...","Please wait...",true,true); 
     } 

     @Override 
     protected void onPostExecute(Bitmap bitmap) { 
      super.onPostExecute(bitmap); 
      loading.dismiss(); 
      imageView.setImageBitmap(bitmap); 
     } 
    } 
    GetImage gi = new GetImage(); 
    gi.execute(urlToImage); 
} 

@Override 
public void onClick(View v) { 
    if(v == buttonFetchImages) { 
     getAllImages(); 
    } 
    if(v == buttonMoveNext){ 
     moveNext(); 
    } 
    if(v== buttonMovePrevious){ 
     movePrevious(); 
    } 
} 
} 

Logcat私を助けることができればそれをいただければ幸いです。