call HTTP Download via Intent - Android Intent

Android examples for Intent:Wifi Connection

Description

call HTTP Download via Intent

Demo Code


import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Looper;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.view.WindowManager;
import android.webkit.URLUtil;

public class Main{
    //  w  w w  .  jav a2s  . c  om
    public static void callHTTPDownload(Context context,
            String chooserTilte, String url) {
        if (null == context) {
            return;
        }
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(URLUtil.guessUrl(url)));
        try {
            context.startActivity(Intent
                    .createChooser(intent, chooserTilte).addFlags(
                            Intent.FLAG_ACTIVITY_NEW_TASK));
        } catch (Exception e) {
            ToastUtils.showToast(context, "failed");
        }
    }
}

Related Tutorials