open In Browser - Android Intent

Android examples for Intent:Browser

Description

open In Browser

Demo Code


//package com.java2s;
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));//from ww  w.  j  a  v  a2s.com
        source.startActivity(myIntent);
    }

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

    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);
    }
}

Related Tutorials