Home | History | Annotate | Download | only in app
      1 package com.android.tests.libstest.app;
      2 
      3 import android.app.Activity;
      4 import android.widget.TextView;
      5 
      6 import java.io.BufferedReader;
      7 import java.io.IOException;
      8 import java.io.InputStream;
      9 import java.io.InputStreamReader;
     10 
     11 public class App {
     12 
     13     public static void handleTextView(Activity a) {
     14         TextView tv = (TextView) a.findViewById(R.id.app_text2);
     15         if (tv != null) {
     16             tv.setText(getContent());
     17         }
     18     }
     19 
     20     private static String getContent() {
     21         InputStream input = App.class.getResourceAsStream("App.txt");
     22         if (input == null) {
     23             return "FAILED TO FIND App.txt";
     24         }
     25 
     26         BufferedReader reader = null;
     27         try {
     28             reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
     29 
     30             return reader.readLine();
     31         } catch (IOException e) {
     32         } finally {
     33             if (reader != null) {
     34                 try {
     35                     reader.close();
     36                 } catch (IOException e) {
     37                 }
     38             }
     39         }
     40 
     41         return "FAILED TO READ CONTENT";
     42     }
     43 }
     44