Phuc Khung
Phuc Khung

Reputation: 29

Load website on Android Application

I have a photo sharing website and I want to build an android app to load my site on android mobile phone.

I've just read this tutorial

How can I remove button "Go to..." and make my app load my site immediately? For example, mobile user clicks on my app icon and my app load the site immediately.

Upvotes: 0

Views: 3682

Answers (2)

Arjun Solanki
Arjun Solanki

Reputation: 236

 WebView myView = (WebView) findViewById(R.id.webview);
 myView.loadUrl("https://stackoverflow.com/");

by using that, you can easily load your website.

Upvotes: 1

magmike
magmike

Reputation: 473

What you ask is simply get rid of the button and just start browsing the given web page.You don't need the button so remove it from your layout.You need your main activity to look like this.

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        WebView myWebView = (WebView) findViewById(R.id.webview);
        myWebView.loadUrl("http://google.com");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

There is no reason to have another class anymore

Upvotes: 1

Related Questions