Я создал приложение, которое использует WebView
. Он работает, однако LogCat
вызывает эту ошибку:
03-27 10:36:35.830: E/eglCodecCommon(1466): **** ERROR unknown type 0x0 (glSizeof,73)
Я понимаю, что 0x0 - неизвестный тип ошибки (в команде Linux), но как я могу это исправить?
Мой код Java
:
@SuppressLint("SetJavaScriptEnabled")
public class MainActivity extends Activity {
/** Called when the activity is first created. */
private WebView edlineWebView;
private ProgressBar progressBar1;
private String currentUrl;
private boolean exitConfirmation;
private BroadcastReceiver completeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Resources res = context.getResources();
Toast.makeText(context, res.getString(R.string.download_complete), Toast.LENGTH_SHORT).show();
startActivity(new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS));
}
};
final Activity activity = this;
@Override
public void onBackPressed() {
if (edlineWebView.copyBackForwardList().getCurrentIndex() > 0) {
edlineWebView.goBack();
}
else {
if (exitConfirmation) {
super.onBackPressed();
return;
}
this.exitConfirmation = true;
Toast.makeText(this, "Press the back key again to exit", Toast.LENGTH_SHORT).show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
exitConfirmation=false;
}
}, 2000);
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.activity_main);
edlineWebView = (WebView) findViewById(R.id.webView1);
progressBar1 = (ProgressBar) findViewById(R.id.progressBar1);
String url = "http://www.edline.net/";
edlineWebView.setWebViewClient(new WebViewClient());
edlineWebView.getSettings().setJavaScriptEnabled(true);
edlineWebView.getSettings().setUserAgentString("Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3");
edlineWebView.loadUrl(url);
edlineWebView.setDownloadListener(new DownloadListener() {
@SuppressLint("DefaultLocale")
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
MimeTypeMap mtm = MimeTypeMap.getSingleton();
DownloadManager downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
Uri downloadUri = Uri.parse(url);
String fileName = downloadUri.getLastPathSegment();
int pos = 0;
if ((pos = contentDisposition.toLowerCase().lastIndexOf("filename=")) >= 0) {
fileName = contentDisposition.substring(pos + 9);
pos = fileName.lastIndexOf(";");
if (pos > 0) {
fileName = fileName.substring(0, pos - 1);
}
}
String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()).toLowerCase();
String mimeType = mtm.getMimeTypeFromExtension(fileExtension);
Request request = new DownloadManager.Request(downloadUri);
request.setTitle(fileName);
request.setDescription(url);
request.setMimeType(mimeType);
request.setDestinationInExternalPublicDir( Environment.DIRECTORY_DOWNLOADS, fileName);
Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_DOWNLOADS).mkdirs();
downloadManager.enqueue(request);
}
});
currentUrl = url;
edlineWebView.setWebChromeClient(new WebChromeClient()
{
public void onProgressChanged(WebView view, int progress)
{
if (progress<100)
{
progressBar1.setVisibility(ProgressBar.VISIBLE);
}
else if (progress==100)
{
progressBar1.setVisibility(ProgressBar.GONE);
}
progressBar1.setProgress(progress);
}
});
edlineWebView.setWebViewClient(new WebViewClient()
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
currentUrl = edlineWebView.getUrl();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url);
return true;
}
});
}
@Override
protected void onPause() {
super.onPause();
unregisterReceiver(completeReceiver);
}
@Override
protected void onResume() {
IntentFilter completeFilter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
registerReceiver(completeReceiver, completeFilter);
super.onResume();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.goto_browser:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(currentUrl));
startActivity(i);
return true;
}
return false;
}
}