Skip to content

Commit 0e947e8

Browse files
committed
example MainActivity truncated
1 parent c86ae40 commit 0e947e8

File tree

1 file changed

+1
-107
lines changed

1 file changed

+1
-107
lines changed

app/src/main/java/com/example/cpp2android/test/MainActivity.java

Lines changed: 1 addition & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,6 @@
1414
public class MainActivity extends AppCompatActivity {
1515
static public native void testNative();
1616

17-
/*class MyObject extends Object {
18-
char payload[] = new char[20000000];
19-
@Override
20-
protected void finalize() throws Throwable {
21-
// int t =payload[1];
22-
Log.i("MEE", "-------------------------------Finalize----------------------");
23-
super.finalize();
24-
}
25-
};
26-
MyObject list = new MyObject ();*/
27-
28-
Thread t;
29-
30-
@Override
31-
public void onTrimMemory(int level) {
32-
Log.i("cpp2android","Trimming");
33-
34-
Runtime.getRuntime().gc();
35-
Runtime.getRuntime().runFinalization();
36-
37-
super.onTrimMemory(level);
38-
}
39-
40-
@Override
41-
public void onLowMemory() {
42-
Log.i("cpp2android","LowMemory");
43-
super.onLowMemory();
44-
}
45-
46-
47-
static long to_kb(long bytes){
48-
return bytes / 1024;
49-
}
50-
static long to_mb(long bytes){
51-
return to_kb(bytes) / 1024;
52-
}
53-
5417
@Override
5518
protected void onCreate(Bundle savedInstanceState) {
5619
super.onCreate(savedInstanceState);
@@ -64,75 +27,6 @@ protected void onCreate(Bundle savedInstanceState) {
6427
final ViewGroup root_view = (ViewGroup)getWindow().getDecorView().getRootView();
6528
final ViewGroup main_layout = (ViewGroup)findViewById(R.id.main_layout);
6629

67-
Log.i("cpp2android", "native allocated heap = " + to_mb(android.os.Debug.getNativeHeapAllocatedSize()));
68-
Log.i("cpp2android", "native heap = " + to_mb(android.os.Debug.getNativeHeapSize()));
69-
Log.i("cpp2android", "free heap = " + to_mb(android.os.Debug.getNativeHeapFreeSize()));
70-
Log.i("cpp2android", "runtime max memory = " + to_mb(Runtime.getRuntime().maxMemory()));
71-
Log.i("cpp2android", "runtime total memory = " + to_mb(Runtime.getRuntime().totalMemory()));
72-
Log.i("cpp2android", "runtime free memory = " + to_mb(Runtime.getRuntime().freeMemory()));
73-
74-
75-
//Runtime.getRuntime().gc();
76-
/*Runtime.getRuntime().gc();
77-
Runtime.getRuntime().gc();
78-
Runtime.getRuntime().gc();
79-
Runtime.getRuntime().gc();
80-
Runtime.getRuntime().gc();
81-
Runtime.getRuntime().gc();
82-
Runtime.getRuntime().gc();
83-
Runtime.getRuntime().gc();
84-
Runtime.getRuntime().gc();
85-
Runtime.getRuntime().gc();*/
86-
87-
//Runtime.getRuntime().runFinalization();
88-
89-
90-
/*final Button text = (Button)findViewById(R.id.sample_text);
91-
t = new Thread(new Runnable() {
92-
int i = 0;
93-
@Override
94-
public void run() {
95-
while (true) {
96-
i++;
97-
runOnUiThread(new Runnable() {
98-
@Override
99-
public void run() {
100-
text.setText(String.valueOf(i));
101-
text.setText(String.valueOf(i));
102-
text.setText(String.valueOf(i));
103-
text.setText(String.valueOf(i));
104-
105-
//text.setText(String.valueOf(i));
106-
//text.setText(String.valueOf(i));
107-
//text.setText(String.valueOf(i));
108-
//text.setText(String.valueOf(i));
109-
}
110-
});
111-
try {
112-
Thread.sleep(1);
113-
} catch (InterruptedException e) {
114-
e.printStackTrace();
115-
}
116-
}
117-
}
118-
});
119-
t.start();
120-
return;*/
121-
122-
123-
124-
//list = new MyObject();
125-
/*MyObject l = new MyObject();
126-
list = null;
127-
list = l;
128-
list = new MyObject();
129-
l = null;*/
130-
131-
/*Runtime.getRuntime().runFinalization();*/
132-
133-
// call C bootstrap
134-
//layout.setOnClickListener(list);
135-
13630
cpp2android.Main.bottstrapJNI(
13731
main_layout.getContext(),
13832
//this.getApplicationContext(),
@@ -152,6 +46,6 @@ public void run() {
15246

15347
public void btnClick(View view) {
15448
testNative();
155-
//signalSender.send(view);
49+
signalSender.send(view);
15650
}
15751
}

0 commit comments

Comments
 (0)