2

I need to develop an app which redirects users to my website right after the app was started.

Thats all I want in my mobile app.

I am using Android studio but I am not familiar with XML. So I am stuck there. Which code should I write to do this redirection? Hope you all can help me. Thank you.

Black
  • 15,426
  • 32
  • 140
  • 232
hakkim
  • 655
  • 14
  • 34
  • 1
    Take a look at the answer to [this question](http://stackoverflow.com/questions/2201917/how-can-i-open-a-url-in-androids-web-browser-from-my-application) – Titus Sep 02 '15 at 06:36
  • so instead of showing splash screen add a web view – Mightian Sep 02 '15 at 06:39

2 Answers2

6

First you need to import this:

import android.content.Intent; 
import android.net.Uri;

In your MainActivity.java class, OnCreate Method you may add

 protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Intent i = new Intent(
            Intent.ACTION_VIEW,
            Uri.parse("http://www.google.com")
        );

// Starts Implicit Activity
        startActivity(i);
    }
Black
  • 15,426
  • 32
  • 140
  • 232
0

You can use a web view in XML file and load your url in it

WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.google.com");