14
14
public class MainActivity extends AppCompatActivity {
15
15
static public native void testNative ();
16
16
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
-
54
17
@ Override
55
18
protected void onCreate (Bundle savedInstanceState ) {
56
19
super .onCreate (savedInstanceState );
@@ -64,75 +27,6 @@ protected void onCreate(Bundle savedInstanceState) {
64
27
final ViewGroup root_view = (ViewGroup )getWindow ().getDecorView ().getRootView ();
65
28
final ViewGroup main_layout = (ViewGroup )findViewById (R .id .main_layout );
66
29
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
-
136
30
cpp2android .Main .bottstrapJNI (
137
31
main_layout .getContext (),
138
32
//this.getApplicationContext(),
@@ -152,6 +46,6 @@ public void run() {
152
46
153
47
public void btnClick (View view ) {
154
48
testNative ();
155
- // signalSender.send(view);
49
+ signalSender .send (view );
156
50
}
157
51
}
0 commit comments