Skip to content

Instantly share code, notes, and snippets.

View pgsamila's full-sized avatar
:octocat:
W I P

Amila Sampath pgsamila

:octocat:
W I P
View GitHub Profile
extern "C"
JNIEXPORT jstring JNICALL
Java_com_example_androidndk_1passing_1complex_1data_NativeLibrary_stringFromJNI(JNIEnv *env, jobject instance) {
std::string hello = "Hello from C++";
return env->NewStringUTF(hello.c_str());
}
/**
* On Get String From JNI Button Clicked Event
*
* @param view
*/
public void onGetStringFromJNIButtonClicked(View view) {
// Define text view to update
TextView textView = findViewById(R.id.textViewGetStringFromJNI);
// Get String From JNI
String[] emptyArray; // Array which not initialized
int[] myNum = {10, 20, 30, 40}; // This is an integer array
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; // This is an Array
for (String i : cars) {
System.out.println(i);
}
for (int i = 0; i < 10; i++) {
System.out.println(i);
}
int count = 0;
do {
System.out.println(count);
count++;
}
while (count < 10);
int count = 0;
while (count < 10) {
System.out.println(count);
count++;
}
int day = 4;
switch (day) {
case 6:
System.out.println("Today is Saturday");
break;
case 7:
System.out.println("Today is Sunday");
break;
default:
System.out.println("Weekday");
int time = 200;
String res = (time < 100) ? "Less Than 100." : "Grater Than 100.";
System.out.println(res);
int time = 200;
if (time < 100) {
System.out.println("Less Than 100.");
} else if (time < 150) {
System.out.println("Between 100 - 150.");
} else {
System.out.println("Greater Than 150.");
}
// Outputs "Greater Than 150."
if (200 > 100) {
System.out.println("200 is greater than 100");
}