|
@ -1,26 +1,27 @@
|
1
|
1
|
package com.ai.ipu.count.test;
|
2
|
2
|
|
3
|
|
import java.io.IOException;
|
4
|
|
import java.util.concurrent.ExecutorService;
|
5
|
|
import java.util.concurrent.Executors;
|
6
|
|
|
7
|
3
|
import android.app.Activity;
|
|
4
|
import android.content.pm.PackageManager;
|
8
|
5
|
import android.os.Bundle;
|
|
6
|
import android.os.SystemClock;
|
9
|
7
|
import android.util.Log;
|
10
|
8
|
import android.view.View;
|
11
|
9
|
import android.view.View.OnClickListener;
|
12
|
10
|
import android.widget.Button;
|
13
|
11
|
import android.widget.LinearLayout;
|
14
|
12
|
import android.widget.LinearLayout.LayoutParams;
|
15
|
|
|
16
|
|
import com.ai.ipu.basic.reflect.IpuReflect;
|
|
13
|
import com.ai.ipu.basic.reflect.ReflectUtil;
|
|
14
|
import com.ai.ipu.count.IpuCount;
|
|
15
|
import com.ai.ipu.count.info.IpuCountReport;
|
17
|
16
|
import com.ai.ipu.count.proxy.IpuCountHolder;
|
18
|
17
|
import com.ai.ipu.count.test.count.ICountBean;
|
19
|
18
|
import com.ai.ipu.count.test.count.impl.TestCountBean;
|
20
|
19
|
import com.ai.ipu.count.test.count.impl.TestCountOtherBean;
|
21
|
20
|
import com.ai.ipu.count.util.IpuCountConstant;
|
22
|
|
import com.ai.ipu.count.util.IpuUDPHelper;
|
23
|
|
import com.ai.ipu.count.util.IpuUDPUtil;
|
|
21
|
|
|
22
|
import java.io.IOException;
|
|
23
|
import java.util.concurrent.ExecutorService;
|
|
24
|
import java.util.concurrent.Executors;
|
24
|
25
|
|
25
|
26
|
public class TestActivity extends Activity {
|
26
|
27
|
private static final String TAG = TestActivity.class.getName();
|
|
@ -66,7 +67,7 @@ public class TestActivity extends Activity {
|
66
|
67
|
// TODO Auto-generated method stub
|
67
|
68
|
try {
|
68
|
69
|
Object obj = IpuCountHolder.getCountInstance(TestCountBean.class);
|
69
|
|
Object result = IpuReflect.invokeMethod(obj, "sayHello", "");
|
|
70
|
Object result = ReflectUtil.invokeMethod(obj, "sayHello", "");
|
70
|
71
|
Log.d(TAG, "返回结果:" + result);
|
71
|
72
|
} catch (Exception e) {
|
72
|
73
|
// TODO Auto-generated catch block
|
|
@ -158,13 +159,12 @@ public class TestActivity extends Activity {
|
158
|
159
|
@Override
|
159
|
160
|
public void onClick(View paramView) {
|
160
|
161
|
// TODO Auto-generated method stub
|
161
|
|
new Thread(new Runnable() {
|
162
|
|
@Override
|
163
|
|
public void run() {
|
164
|
|
IpuUDPHelper.sendReport(getApplicationContext(), "Hello UDP");
|
165
|
|
}
|
166
|
|
}).start();
|
167
|
|
}
|
|
162
|
try {
|
|
163
|
IpuCount.send("Hello UDP");
|
|
164
|
} catch (PackageManager.NameNotFoundException e) {
|
|
165
|
e.printStackTrace();
|
|
166
|
}
|
|
167
|
}
|
168
|
168
|
});
|
169
|
169
|
layout.addView(button);
|
170
|
170
|
|
|
@ -174,14 +174,42 @@ public class TestActivity extends Activity {
|
174
|
174
|
button.setOnClickListener(new View.OnClickListener() {
|
175
|
175
|
@Override
|
176
|
176
|
public void onClick(View v) {
|
177
|
|
try {
|
178
|
|
IpuUDPUtil.FileUtil.getInstance().clear(IpuCountConstant.LOG_FILE_NAME);
|
179
|
|
} catch (IOException e) {
|
180
|
|
e.printStackTrace();
|
181
|
|
}
|
|
177
|
// try {
|
|
178
|
// IpuUDPUtil.FileUtil.getInstance().clear(IpuCountConstant.LOG_FILE_NAME);
|
|
179
|
// } catch (IOException e) {
|
|
180
|
// e.printStackTrace();
|
|
181
|
// }
|
182
|
182
|
}
|
183
|
183
|
});
|
184
|
184
|
layout.addView(button);
|
|
185
|
|
|
186
|
button = new Button(this);
|
|
187
|
button.setText("8-发送设备日志");
|
|
188
|
button.setOnClickListener(new View.OnClickListener() {
|
|
189
|
@Override
|
|
190
|
public void onClick(View v) {
|
|
191
|
try {
|
|
192
|
IpuCount.sendDevice("设备日志");
|
|
193
|
} catch (PackageManager.NameNotFoundException e) {
|
|
194
|
e.printStackTrace();
|
|
195
|
}
|
|
196
|
}
|
|
197
|
});
|
|
198
|
layout.addView(button);
|
|
199
|
|
|
200
|
button = new Button(this);
|
|
201
|
button.setText("9-发送插件日志");
|
|
202
|
button.setOnClickListener(new View.OnClickListener() {
|
|
203
|
@Override
|
|
204
|
public void onClick(View v) {
|
|
205
|
try {
|
|
206
|
IpuCount.sendPlugin(SystemClock.currentThreadTimeMillis(),"Plugin Action");
|
|
207
|
} catch (PackageManager.NameNotFoundException e) {
|
|
208
|
e.printStackTrace();
|
|
209
|
}
|
|
210
|
}
|
|
211
|
});
|
|
212
|
layout.addView(button);
|
185
|
213
|
|
186
|
214
|
setContentView(layout);
|
187
|
215
|
}
|