2013-05-31 1 views
0

안드로이드 2.3.3캐치되지 않는 형식 오류 :에 정의되지 않은 방법 '의 setAttribute'을 호출 할 수 없습니다 - 나는에서 스크립트/HTML을 요청을 얻을 HTTP를 사용하고 (AD)를 얻기 위해 노력하고 있어요 HTTP 응답을

를 표시하는 중에 섬기는 사람. 응답을 얻은 후에 WebView에 응답을 첨부하려고합니다. 매번 서버에서 응답을 올바르게받습니다. 나는 HTML이나 Script를 얻는다. 그러나 때로는 광고가 표시되거나 때로는 표시되지 않습니다. AsyncTask를 - -

 05-31 15:36:33.339: E/Web Console(10861): Uncaught TypeError: Cannot call method 'setAttribute' of undefined at 
http://lp.xxx.xx/rich/T/test_suite/smartphone/320x50_ex_launch.php?mm_view=js&mm_urid=ZyAOlvcAeXFxzt4seOQ0WWwL&mm_ipaddress=49.205.242.120 
    &mm_handset=3768&mm_carrier=0&mm_apid=xxxxx&mm_acid=465355&mm_osid=58 
    &mm_uip=49.205.242.120&mm_ua=Apache-HttpClient%2FUNAVAILABLE+%28java+1.4%29 
    &mm_mtpid=0&mm_hswd=320&mm_hsht=53 
    &mm_auid=mmid_11a58a0069120505278791da8d22d5ad28_013ec7373911 
    &mm_country=100&mm_orut=1369994770&mm_mmid=3768:495 

자바 코드 ... 아래 사항

로그 캣을 참조하십시오

알려 주시기 바랍니다 MainActivity

private static GetMMediaAdsTask mGetMMediaAds; 

static String responseBody = ""; 

StringBuffer html = new StringBuffer(); 
.... 
.... 
html.append("<p>"); 
String url = "http://xxxx.com/getAd"; 

mGetMMediaAds = new GetMMediaAdsTask(context); 
mGetMMediaAds.execute(url); // Calling the execute method of asynctask 

... 
... 
... 
html.append(responseBody); 
html.append("</p>"); 
public static class GetMMediaAdsTask extends AsyncTask<String, Void, Boolean>{ 

    String url = "http://ads.mp.xxx.xx/getAd"; 
    String apid = "xxx"; 
    String auid = ""; 

    String returned = ""; 

    private Context mContext; 
    private ProgressDialog progressDialog; 


    public GetMMediaAdsTask(Context context) { 
     // TODO Auto-generated constructor stub 
     mContext = context; 
    } 


    @Override 
    protected void onPreExecute() { 
     // TODO Auto-generated method stub 

     progressDialog = new ProgressDialog(mContext);  
     progressDialog.setIndeterminate(true); 
     progressDialog.setMessage("Loading..."); 
     progressDialog.show(); 


     super.onPreExecute(); 
    } 


    @Override 
    protected Boolean doInBackground(String... params) { 
     // TODO Auto-generated method stub 

     System.out.println("***** Inside AsyncTask *****"); 

     auid = Secure.getString(mContext.getContentResolver(), Secure.ANDROID_ID); 

     int hsht = 0; 
     int hswd = 0; 

     DisplayMetrics metrics = new DisplayMetrics(); 
     ((Activity) mContext).getWindowManager().getDefaultDisplay().getMetrics(metrics); 

     int height = metrics.heightPixels; 
     int width = metrics.widthPixels; 

     System.out.println("Height ="+height+" Width = "+width); 

     if(width <= 320) 
     { 
      hswd = 320; 
      hsht = 53; 
     } 
     else if(width > 320 && width < 468) 
     { 
      hswd = 320; 
      hsht = 53; 
     } 
     else if(width >= 468 && width < 728) 
     { 
      hswd = 468; 
      hsht = 60; 
     } 
     else if(width >= 728) 
     { 
      hswd = 728; 
      hsht = 90; 
     } 

     String query = String.format("apid=%s&auid=%s&hsht=%d&hswd=%d", apid, auid, hsht, hswd); 
     System.out.println("query = "+query); 

     try { 
      DefaultHttpClient http = new DefaultHttpClient(); 
      HttpGet httpMethod = new HttpGet(); 
      httpMethod.setURI(new URI(url + "?" + query)); 
      HttpResponse response = http.execute(httpMethod); 
      int responseCode = response.getStatusLine().getStatusCode(); 

      System.out.println("Response Code = "+ responseCode); 

      switch (responseCode) { 
      case 200: 
       HttpEntity entity = response.getEntity(); 
       if (entity != null) { 
        returned = ""; 
        returned = EntityUtils.toString(entity); 
        System.out.println("response = "+returned); 

       } 
       break; 
      } 

     } catch (Exception e) { 
      System.out.println("Exception occured"); 
     } 



     return true; 
    } 

    @Override 
    protected void onPostExecute(Boolean result) { 
     // TODO Auto-generated method stub 

     System.out.println("***** Inside PostExecute *****"); 
     responseBody = returned; 
     System.out.println("responseBody = "+responseBody); 

     mViewPager.setAdapter(mArticlePagerAdapter); 
     mViewPager.setCurrentItem(mPosition); 
     mViewPager.setOnPageChangeListener(new OnPageChangeListener() { 
      @Override 
      public void onPageSelected(int position) { 
       setShareIntent(position); 
       if (mOnPageSelectedListener != null) 
        mOnPageSelectedListener.onPageSelected(position); 
      } 

      @Override 
      public void onPageScrolled(int arg0, float arg1, int arg2) { 
      } 

      @Override 
      public void onPageScrollStateChanged(int arg0) { 
      } 
     }); 


     progressDialog.dismiss(); 

     super.onPostExecute(result); 
    } 

} 

미세

코드를 작동, 필요한 것이 있으면 ... 감사합니다

답변

0

Millennial Media 게재 위치가 확장형 배너를 요구하는 것 같습니다. 서버 간 구현을 사용하는 경우 Millennial Media는 확장 가능한 배너를 지원하지 않습니다. 오류는 자바 스크립트를 찾지 못한다는 것을 말하는 것입니다. 이 경우 확장형 배너를 허용하지 않도록 게재 위치를 변경하는 것이 가장 좋습니다.

, 당신을 감사

아론