1 package com.example.ioraptestapp; 2 3 import androidx.annotation.RequiresApi; 4 import androidx.appcompat.app.AppCompatActivity; 5 6 import android.os.Build; 7 import android.os.Bundle; 8 import android.util.Log; 9 import android.widget.TextView; 10 11 import java.io.BufferedReader; 12 import java.io.IOException; 13 import java.io.InputStream; 14 import java.io.InputStreamReader; 15 16 public class MainActivity extends AppCompatActivity { 17 18 @RequiresApi(api = Build.VERSION_CODES.KITKAT) 19 @Override onCreate(Bundle savedInstanceState)20 protected void onCreate(Bundle savedInstanceState) { 21 super.onCreate(savedInstanceState); 22 setContentView(R.layout.activity_main); 23 try { 24 LoadText(R.raw.testfile); 25 } catch (InterruptedException e) { 26 e.printStackTrace(); 27 } 28 TextView view = this.findViewById(R.id.textView); 29 String text = "Version: " + BuildConfig.VERSION_CODE; 30 view.setText(text); 31 32 } 33 34 @RequiresApi(api = Build.VERSION_CODES.KITKAT) LoadText(int resourceId)35 public void LoadText(int resourceId) throws InterruptedException { 36 // The InputStream opens the resourceId and sends it to the buffer 37 InputStream is = this.getResources().openRawResource(resourceId); 38 BufferedReader br = new BufferedReader(new InputStreamReader(is)); 39 String readLine = null; 40 41 try { 42 // While the BufferedReader readLine is not null 43 while ((readLine = br.readLine()) != null) { 44 Log.d("TEXT", readLine); 45 } 46 47 // Close the InputStream and BufferedReader 48 is.close(); 49 br.close(); 50 51 } catch (IOException e) { 52 e.printStackTrace(); 53 } 54 Thread.sleep(100); 55 this.reportFullyDrawn(); 56 } 57 } 58