У меня есть CustomWebViewClass:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
public class CustomWebView extends Activity{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String url = intent.getStringExtra("url");
WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
//progress bar optional
getWindow().requestFeature(Window.FEATURE_PROGRESS);
final Activity activity = this;
Toast.makeText(activity, "YO! " + url, Toast.LENGTH_SHORT).show();
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
activity.setProgress(progress * 1000);
}
});
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
webview.loadUrl(url);
}
}
из другого класса (по сути, кнопка). Я пытаюсь вызвать этот класс как намерение, передав ему URL-адрес примерно так:
Intent webView = new Intent(getContext(), CustomWebView.class);
webView.putExtra("url", "http://google.com");
webView.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(webView);
но я получаю черный экран или ошибку .. очевидно, я делаю что-то не так, пожалуйста, помогите
о, и мой манифест имеет это:
<activity android:name=".CustomWebView"
android:label="CustomWebView"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="com.sapientnitro.lcinstore2.CUSTOMWEBVIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>