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 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥20 jupyter保存图像功能的实现
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键