Show general help in the browser using Intent. - Android Intent

Android examples for Intent:Browser

Description

Show general help in the browser using Intent.

Demo Code


//package com.java2s;
import android.app.Activity;

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

public class Main {
    /**/*from   ww  w  .  java 2  s . c  o  m*/
     * URL for general help.
     */
    protected final static String HELP_URL = "http://your url";

    /**
     * Show general help in the browser.
     * 
     * @param fromActivity
     *            the source activity.
     */
    protected static void doHelp(Activity fromActivity) {
        doLaunchBrowser(fromActivity, HELP_URL);
    }

    /**
     * End this activity and launch a non-CSV URL.
     * 
     * This method invokes {@link #finish()}.
     * 
     * @param fromActivity
     *            the source activity.
     * @param url
     *            The URL to launch in the browser (etc.).
     */
    protected static void doLaunchBrowser(Activity fromActivity, String url) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        fromActivity.startActivity(intent);
    }
}

Related Tutorials