I tried to make the user click on a particular button, it was directed to a website, in this case google, but it did not work.
The app starts normally, but when you click the button the app stops at nothing:
Thisappearsintheeventlog:
NullPointerException:Errorexecutingtaskcom.android.tools.idea.uibuilder.editor.NlPreviewForm$$Lambda$186/56197713@4193ab80
MainActivity.java:
package genesysgeneration.bb;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
private Button btnSite;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnSite=(Button)findViewById(R.id.btnsite);
btnSite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent it = new Intent(Intent.ACTION_VIEW, Uri.parse("www.google.com"));
startActivity(it);
}
});
}
}