-2
我正在從WebView
中創建應用程序,我需要做的是將圖像上傳到database
。我正在使用Navigation Bar Activity
並在Navigation Bar
的頂部我有一個項目,它將它重定向到可以上傳圖像的頁面。從webview中點擊輸入文件時,應用程序崩潰
我添加了一些後端代碼,但每當我嘗試點擊它,應用程序崩潰,並說「應用程序已停止工作」和logcat錯誤不包含任何異常。
這是我的代碼:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
if (item.getItemId() == R.id.addPost) {
WebView web = (WebView)findViewById(R.id.layoutHome);
web.setWebViewClient(new WebViewClient());
webSettings.setJavaScriptEnabled(true);
webSettings = web.getSettings();
webSettings.setLoadWithOverviewMode(true);
webSettings.setAllowFileAccess(true);
webView.setWebViewClient(new Client());
webView.setWebChromeClient(new ChromeClient());
if (Build.VERSION.SDK_INT >= 19) {
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
else if(Build.VERSION.SDK_INT >=11 && Build.VERSION.SDK_INT < 19) {
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
web.loadUrl("http://192.168.0.10/BuyAndSell/Mobile/addItem.php");
}
//noinspection SimplifiableIfStatement
return super.onOptionsItemSelected(item);
}
編輯:logcat的
04-05 14:46:07.320 1554-14992/? V/FA: Using measurement service
04-05 14:46:07.320 1554-14992/? V/FA: Connecting to remote service
04-05 14:46:07.330 1554-14992/? V/FA: Activity resumed, time: 34708363
04-05 14:46:07.810 1554-14992/? D/FA: Connected to remote service
04-05 14:46:07.810 1554-14992/? V/FA: Processing queued up service tasks: 1
它是否引發空指針異常?好像可能是! – Piyush
顯示你的logcat – kggoh
@Piyush我的logcat沒有說任何關於它是NPE的 – phpnewbs