Back to project page android_tutorial_projects.
The source code is released under:
Copyright (c) 2013, Uthcode All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redi...
If you think the Android project android_tutorial_projects listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.uthcode.registeredintent; /* w w w .j av a2 s . c o m*/ import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.StrictMode; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBar; import android.support.v4.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.os.Build; import android.widget.TextView; import org.apache.http.conn.ssl.StrictHostnameVerifier; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; public class BrowserActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); setContentView(R.layout.activity_browser); Intent intent = getIntent(); TextView text = (TextView) findViewById(R.id.textView); // To get the action of the intent use String action = intent.getAction(); if (!action.equals(Intent.ACTION_VIEW)) { throw new RuntimeException("Should not happen."); } Uri data = intent.getData(); URL url; try { url = new URL(data.getScheme(), data.getHost(), data.getPath()); BufferedReader rd = new BufferedReader(new InputStreamReader(url.openStream())); String line = ""; while ((line = rd.readLine()) != null) { text.append(line); } } catch (Exception e) { e.printStackTrace(); } } }