Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.content.Intent;

import android.net.Uri;

import android.text.TextUtils;

import android.util.Log;

public class Main {
    public static void openBrowser(Context context, String url) {
        if (!TextUtils.isEmpty(url)) {
            if (!url.startsWith("http://") && !url.startsWith("https://")) {
                url = "http://" + url;
            }
            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        } else {
            Log.e("Helpers#openBrowser", "Something isn't right about the URL passed");
        }
    }
}