open In Browser - Android android.content

Android examples for android.content:Intent

Description

open In Browser

Demo Code

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

public class Main{

    public static void openInBrowser(Activity source, String siteHttp) {
        Intent myIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(siteHttp));/*w w  w .  j  a  v a  2  s . c om*/
        source.startActivity(myIntent);
    }
    public static void startActivity(Activity root, Class<?> activityClass,
            Bundle extras) {
        if (extras == null) {
            throw new RuntimeException(
                    "Bundle is null, use method without bundle.");
        }

        Intent intent = new Intent(root, activityClass);
        intent.putExtras(extras);
        root.startActivity(intent);
    }
    public static void startActivity(Activity root, Class<?> activityClass) {
        Intent intent = new Intent(root, activityClass);
        root.startActivity(intent);
    }

}

Related Tutorials