Reputation: 31
i have this problem : java.lang.NullPointerException
My Codes and LogCat pictures :
WebviewActivity.class
public class WebviewActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
Bundle alinan = getIntent().getExtras();
String alinmis = alinan.getString("veri");
WebView webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(alinmis);
webView.getSettings().setBuiltInZoomControls(true);
webView.setWebChromeClient(new WebChromeClient() {
});
MenutrActivity.class
public class MenutrActivity extends Activity{
Bundle bnd;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menutr);
bnd = new Bundle();
Button mekanlar = (Button)findViewById(R.id.mekanlar);
final Intent i = new Intent(getApplicationContext(), WebviewActivity.class);
mekanlar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent("android.intent.action.WEBK"));
String myString = "http://www.google.com.tr";
bnd.putString("veri", myString);
i.putExtras(bnd);
startActivity(i);
}
}); }}
application fails when I press the button.
LogCat error : java.lang.NullPointerException in WebviewActivity.class
Upvotes: 0
Views: 174
Reputation: 806
First of all change "StartActivity(new Intent...." to "Intent i = new Intent(...". You call the activity before putting extra.
Next time just copy your code and paste as a code. This way it is very hard to see...
Upvotes: 2