106956f3dd31a7e71bac119982a9a7db31259050eYabin Cuipackage com.example.simpleperf.simpleperfexamplewithnative; 206956f3dd31a7e71bac119982a9a7db31259050eYabin Cui 306956f3dd31a7e71bac119982a9a7db31259050eYabin Cuiimport android.support.v7.app.AppCompatActivity; 406956f3dd31a7e71bac119982a9a7db31259050eYabin Cuiimport android.os.Bundle; 506956f3dd31a7e71bac119982a9a7db31259050eYabin Cuiimport android.widget.TextView; 606956f3dd31a7e71bac119982a9a7db31259050eYabin Cui 706956f3dd31a7e71bac119982a9a7db31259050eYabin Cuipublic class MainActivity extends AppCompatActivity { 806956f3dd31a7e71bac119982a9a7db31259050eYabin Cui 906956f3dd31a7e71bac119982a9a7db31259050eYabin Cui // Used to load the 'native-lib' library on application startup. 1006956f3dd31a7e71bac119982a9a7db31259050eYabin Cui static { 1106956f3dd31a7e71bac119982a9a7db31259050eYabin Cui System.loadLibrary("native-lib"); 1206956f3dd31a7e71bac119982a9a7db31259050eYabin Cui } 1306956f3dd31a7e71bac119982a9a7db31259050eYabin Cui 1406956f3dd31a7e71bac119982a9a7db31259050eYabin Cui @Override 1506956f3dd31a7e71bac119982a9a7db31259050eYabin Cui protected void onCreate(Bundle savedInstanceState) { 1606956f3dd31a7e71bac119982a9a7db31259050eYabin Cui super.onCreate(savedInstanceState); 1706956f3dd31a7e71bac119982a9a7db31259050eYabin Cui setContentView(R.layout.activity_main); 1806956f3dd31a7e71bac119982a9a7db31259050eYabin Cui 1906956f3dd31a7e71bac119982a9a7db31259050eYabin Cui // Example of a call to a native method 2006956f3dd31a7e71bac119982a9a7db31259050eYabin Cui TextView tv = (TextView) findViewById(R.id.sample_text); 2106956f3dd31a7e71bac119982a9a7db31259050eYabin Cui tv.setText(stringFromJNI()); 2206956f3dd31a7e71bac119982a9a7db31259050eYabin Cui 2306956f3dd31a7e71bac119982a9a7db31259050eYabin Cui createBusyThreadFromJNI(); 2406956f3dd31a7e71bac119982a9a7db31259050eYabin Cui } 2506956f3dd31a7e71bac119982a9a7db31259050eYabin Cui 2606956f3dd31a7e71bac119982a9a7db31259050eYabin Cui /** 2706956f3dd31a7e71bac119982a9a7db31259050eYabin Cui * A native method that is implemented by the 'native-lib' native library, 2806956f3dd31a7e71bac119982a9a7db31259050eYabin Cui * which is packaged with this application. 2906956f3dd31a7e71bac119982a9a7db31259050eYabin Cui */ 3006956f3dd31a7e71bac119982a9a7db31259050eYabin Cui public native String stringFromJNI(); 3106956f3dd31a7e71bac119982a9a7db31259050eYabin Cui 3206956f3dd31a7e71bac119982a9a7db31259050eYabin Cui private native void createBusyThreadFromJNI(); 3306956f3dd31a7e71bac119982a9a7db31259050eYabin Cui} 34