struggle100403 2016-04-28 07:23 采纳率: 0%
浏览 1563

各位高手,帮我分析以下代码在安卓手机上运行时报错的原因!

//MainActivity.java如下:
```import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings.RenderPriority;
import android.webkit.WebView;
import android.webkit.WebViewClient;

    public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

WebView browser=(WebView)findViewById(R.id.Toweb);  
browser.loadUrl("http://58.215.195.18:10010/login_person.jsp");  //在此app不能上网提示“Proxy_Error",但UC浏览器和电脑都能上

browser.getSettings().setSupportZoom(true);  
browser.getSettings().setBuiltInZoomControls(true);  
browser.getSettings().setJavaScriptEnabled(true);
browser.getSettings().setDomStorageEnabled(true);
browser.getSettings().setBlockNetworkImage(true);
browser.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
browser.getSettings().setAllowFileAccess(true);
browser.getSettings().setAppCacheEnabled(true); 
browser.getSettings().setSaveFormData(false);
browser.getSettings().setLoadsImagesAutomatically(true);
browser.setWebViewClient(new WebViewClient() {  
    public boolean shouldOverrideUrlLoading(WebView view, String url)  
    {   

        view.loadUrl(url);  
                return true;  
    }         
     }); 
}  

@Override  
public boolean onKeyDown(int keyCode, KeyEvent event) {  
WebView browser=(WebView)findViewById(R.id.Toweb);  
// Check if the key event was the Back button and if there's history  
if ((keyCode == KeyEvent.KEYCODE_BACK) && browser.canGoBack()) {  
    browser.goBack();  
    return true;  
}  
return super.onKeyDown(keyCode, event);  
} 


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}
} ```

//activity_main.xml如下:

      xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.wuxireservedfunds.MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

    <WebView android:id="@+id/Toweb"  
        android:layout_width="fill_parent"  
        android:layout_height="fill_parent" /> 

</RelativeLayout>```

//AndroidManifest.xml如下:
```<?xml version="1.0" encoding="utf-8"?>
   <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.wuxireservedfunds"
    android:versionCode="1"
    android:versionName="1.0" >
     <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="21" />
     <uses-permission 
            android:name="android.permission.INTERNET">
        </uses-permission>  
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest> ```


在eclipse中编译时并没有错误提示,是apk在模拟器和手机运行时报错误,具体如下:
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /login_person.jsp.
Reason:Error reading from remote server

但是网址:http://58.215.195.18:10010/login_person.jsp却能在手机的uc浏览器
和电脑上正常打开,真是百思不得其解!高手们,出马啊!拜托了!




  • 写回答

4条回答

  • 好一个大布丁 博客专家认证 2016-04-28 23:25
    关注

    你得贴错误日志呀!不然不好找到错误的原因

    评论

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler