LicenseActivity.java 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package com.usai.redant.photo;
  2. import java.io.InputStream;
  3. import org.apache.http.util.EncodingUtils;
  4. import android.app.Activity;
  5. import android.os.Bundle;
  6. import android.view.Menu;
  7. import android.view.MenuItem;
  8. import android.webkit.WebView;
  9. public class LicenseActivity extends Activity
  10. {
  11. @Override
  12. protected void onCreate(Bundle savedInstanceState)
  13. {
  14. super.onCreate(savedInstanceState);
  15. setContentView(R.layout.activity_license);
  16. WebView wv = (WebView) findViewById(R.id.webView1);
  17. String content = "";
  18. try
  19. {
  20. InputStream in = getResources().openRawResource(R.raw.license);
  21. // 获取文件的字节数
  22. int lenght = in.available();
  23. // 创建byte数组
  24. byte[] buffer = new byte[lenght];
  25. // 将文件中的数据读到byte数组中
  26. in.read(buffer);
  27. content = EncodingUtils.getString(buffer, "UTF-8");
  28. }
  29. catch (Exception e)
  30. {
  31. e.printStackTrace();
  32. }
  33. wv.getSettings().setDefaultTextEncodingName("UTF-8");
  34. wv.loadData(content, "text/html", null);
  35. }
  36. // @Override
  37. // public boolean onCreateOptionsMenu(Menu menu)
  38. // {
  39. // // Inflate the menu; this adds items to the action bar if it is present.
  40. // getMenuInflater().inflate(R.menu.license, menu);
  41. // return true;
  42. // }
  43. //
  44. // @Override
  45. // public boolean onOptionsItemSelected(MenuItem item)
  46. // {
  47. // // Handle action bar item clicks here. The action bar will
  48. // // automatically handle clicks on the Home/Up button, so long
  49. // // as you specify a parent activity in AndroidManifest.xml.
  50. // int id = item.getItemId();
  51. // if (id == R.id.action_settings)
  52. // {
  53. // return true;
  54. // }
  55. // return super.onOptionsItemSelected(item);
  56. // }
  57. }