Android Open Source - blog-reader Blog Web View Activity






From Project

Back to project page blog-reader.

License

The source code is released under:

GNU General Public License

If you think the Android project blog-reader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ca.exilium.blogreader;
/*w  ww. ja va 2  s  .c  om*/
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;

import ca.exilium.blogreader.R;

public class BlogWebViewActivity extends Activity {

  protected String _url;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_blog_web_view);

    Intent intent = getIntent();
    Uri blogUrl = intent.getData();

    WebView webView = (WebView) findViewById(R.id.webView);
    _url = blogUrl.toString();
    webView.loadUrl(_url);
  }


  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.blog_web_view, menu);
    return true;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_share) {
      sharePost();
    }

    return super.onOptionsItemSelected(item);
  }

  private void sharePost() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, _url);
    startActivity(Intent.createChooser(shareIntent, "How do you want to share?"));
  }
}




Java Source Code List

ca.exilium.blogreader.ApplicationTest.java
ca.exilium.blogreader.BlogWebViewActivity.java
ca.exilium.blogreader.MainListActivity.java