Skip to content Skip to sidebar Skip to footer

How To Open Any Website In Android Application In Android Studio

I just started a new appliction using android studio .. but i need to open a web page in my application i tried using web view but it doesnt worked out... when i open my app it cra

Solution 1:

Call super method and setcontentview first. Only after setContentView you can access to the functions findViewByid and all

From the documentation

setContentView(int resLayout): Set the activity content from a layout resource. The resource will be inflated, adding all top-level views to the activity.

So if it isn't called no views will be added to your activity. Then you cant access any views at all.

Change it like this

@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_references);


   wb=(WebView)findViewById(R.id.web_view);
    WebSettings webSettings=wb.getSettings();
    webSettings.setJavaScriptEnabled(true);
    wb.loadUrl("https://www.google.co.in");
}

Post a Comment for "How To Open Any Website In Android Application In Android Studio"