質問編集履歴
4
タグを編集しました
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
3
MainActivity\.javaを、スレッドを使用した内容に変更いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
2016年11月23日に「MainActivity.java」を更新いたしました。
|
2
2
|
|
3
|
+
2016年12月1日に「MainActivity.java」を更新いたしました。
|
4
|
+
|
3
5
|
|
4
6
|
|
5
7
|
Android Studio 2.1.0.0
|
@@ -24,478 +26,460 @@
|
|
24
26
|
|
25
27
|
実際には1秒間で15回ほど更新→更新中止をしたいと思っております。
|
26
28
|
|
29
|
+
|
30
|
+
|
31
|
+
・バージョンの違うAndroid端末でも同じ動作をさせるため、XWalkViewを使用しました。
|
32
|
+
|
33
|
+
・更新ボタン、更新中止ボタンを押すことでWebページの更新、更新中止の動作はできました。
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
どのようにすれば、表示されているWebページを更新してすぐに更新中止という動作を高速で繰り返す事ができるでしょうか。
|
38
|
+
|
39
|
+
何卒、ご教授をよろしくお願いいたします。
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
以下に、動作確認をした際の「MainActivity.java」「activity_main.xml」「AndroidManifest.xml」の内容を示します。
|
48
|
+
|
49
|
+
ご参照いただけますと幸いです。
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
MainActivity.java
|
54
|
+
|
27
55
|
```java
|
28
56
|
|
57
|
+
package パッケージ名
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
import android.app.Activity;
|
62
|
+
|
63
|
+
import android.app.ProgressDialog;
|
64
|
+
|
65
|
+
import android.os.Bundle;
|
66
|
+
|
67
|
+
import android.os.Handler;
|
68
|
+
|
69
|
+
import android.view.View;
|
70
|
+
|
71
|
+
import android.view.View.OnClickListener;
|
72
|
+
|
73
|
+
import android.widget.Button;
|
74
|
+
|
75
|
+
import android.widget.TextView;
|
76
|
+
|
77
|
+
import android.support.v7.app.ActionBarActivity;
|
78
|
+
|
79
|
+
import org.xwalk.core.XWalkView;
|
80
|
+
|
81
|
+
import org.xwalk.core.internal.XWalkCookieManager;
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
public class MainActivity extends Activity {
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
Handler mHandler;
|
90
|
+
|
91
|
+
private ProgressDialog progressDialog;
|
92
|
+
|
93
|
+
private XWalkView mXWalkView;
|
94
|
+
|
95
|
+
private XWalkCookieManager mCookieManager;
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
@Override
|
100
|
+
|
101
|
+
public void onCreate(Bundle savedInstanceState) {
|
102
|
+
|
103
|
+
super.onCreate(savedInstanceState);
|
104
|
+
|
105
|
+
setContentView(R.layout.activity_main);
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
//mXWalkViewを作成
|
110
|
+
|
111
|
+
mXWalkView = (XWalkView) findViewById(R.id.xwalkWebView);
|
112
|
+
|
113
|
+
mXWalkView.load("対象のサイト", null);
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
//クッキーの設定
|
118
|
+
|
119
|
+
XWalkCookieManager mCookieManager = new XWalkCookieManager();
|
120
|
+
|
121
|
+
mCookieManager.setAcceptCookie(false);
|
122
|
+
|
123
|
+
mCookieManager.setAcceptFileSchemeCookies(false);
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
//ProgressDialogを生成します。
|
128
|
+
|
129
|
+
progressDialog = new ProgressDialog(this);
|
130
|
+
|
131
|
+
progressDialog.setMessage("実行中です。");
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
//ハンドラを生成
|
136
|
+
|
137
|
+
mHandler = new Handler();
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
((Button)findViewById(R.id.button1)).setOnClickListener(new View.OnClickListener() {
|
142
|
+
|
143
|
+
@Override
|
144
|
+
|
145
|
+
public void onClick(View v) {
|
146
|
+
|
147
|
+
mXWalkView.reload(0);
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
});
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
((Button)findViewById(R.id.button2)).setOnClickListener(new View.OnClickListener() {
|
156
|
+
|
157
|
+
@Override
|
158
|
+
|
159
|
+
public void onClick(View v) {
|
160
|
+
|
161
|
+
mXWalkView.stopLoading();
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
});
|
166
|
+
|
167
|
+
|
168
|
+
|
29
169
|
((Button)findViewById(R.id.button3)).setOnClickListener(new View.OnClickListener() {
|
30
170
|
|
31
171
|
@Override
|
32
172
|
|
33
173
|
public void onClick(View v) {
|
34
174
|
|
35
|
-
new Thread(new Runnable() {
|
36
|
-
|
37
|
-
@Override
|
38
|
-
|
39
|
-
public void run() {
|
40
|
-
|
41
|
-
handler.post(new Runnable() {
|
42
|
-
|
43
|
-
public void run() {
|
44
|
-
|
45
|
-
|
175
|
+
for(int fa = 0; fa < 10; fa++) {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
176
|
+
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
try {//スリープ
|
54
|
-
|
55
|
-
|
177
|
+
buttonProcess();
|
56
|
-
|
57
|
-
|
178
|
+
|
58
|
-
|
59
|
-
|
179
|
+
}
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
mXWalkView.stopLoading();
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
try {//スリープ
|
68
|
-
|
69
|
-
Thread.sleep(30);
|
70
|
-
|
71
|
-
} catch (InterruptedException e) {
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
}
|
76
|
-
|
77
|
-
}
|
78
|
-
|
79
|
-
});
|
80
|
-
|
81
|
-
}
|
82
|
-
|
83
|
-
}).start();
|
84
180
|
|
85
181
|
}
|
86
182
|
|
87
183
|
});
|
88
184
|
|
185
|
+
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
@Override
|
192
|
+
|
193
|
+
protected void onPause() {
|
194
|
+
|
195
|
+
super.onPause();
|
196
|
+
|
197
|
+
if (mXWalkView != null) {
|
198
|
+
|
199
|
+
mXWalkView.pauseTimers();
|
200
|
+
|
201
|
+
mXWalkView.onHide();
|
202
|
+
|
203
|
+
}
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
@Override
|
210
|
+
|
211
|
+
protected void onResume() {
|
212
|
+
|
213
|
+
super.onResume();
|
214
|
+
|
215
|
+
if (mXWalkView != null) {
|
216
|
+
|
217
|
+
mXWalkView.resumeTimers();
|
218
|
+
|
219
|
+
mXWalkView.onShow();
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
@Override
|
228
|
+
|
229
|
+
protected void onDestroy() {
|
230
|
+
|
231
|
+
super.onDestroy();
|
232
|
+
|
233
|
+
if (mXWalkView != null) {
|
234
|
+
|
235
|
+
mXWalkView.onDestroy();
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
//buttonがクリックされた時の処理
|
246
|
+
|
247
|
+
private void buttonProcess() {
|
248
|
+
|
249
|
+
//ProgressDialogを表示します。
|
250
|
+
|
251
|
+
progressDialog.show();
|
252
|
+
|
253
|
+
//画面更新
|
254
|
+
|
255
|
+
mXWalkView.reload(0);
|
256
|
+
|
257
|
+
//スレッドを生成して起動します。
|
258
|
+
|
259
|
+
MyThread thread = new MyThread();
|
260
|
+
|
261
|
+
thread.start();
|
262
|
+
|
263
|
+
}
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
class MyThread extends Thread {
|
268
|
+
|
269
|
+
public void run() {
|
270
|
+
|
271
|
+
try {
|
272
|
+
|
273
|
+
Thread.sleep(100);
|
274
|
+
|
275
|
+
} catch (InterruptedException e) {
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
//メインスレッドのメッセージキューにメッセージを登録します。
|
280
|
+
|
281
|
+
mHandler.post(new Runnable() {
|
282
|
+
|
283
|
+
//run()の中の処理はメインスレッドで動作されます。
|
284
|
+
|
285
|
+
public void run() {
|
286
|
+
|
287
|
+
//画面更新中止
|
288
|
+
|
289
|
+
mXWalkView.stopLoading();
|
290
|
+
|
291
|
+
//ProgressDialogを消去します。
|
292
|
+
|
293
|
+
progressDialog.dismiss();
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
});
|
298
|
+
|
299
|
+
try {
|
300
|
+
|
301
|
+
Thread.sleep(100);
|
302
|
+
|
303
|
+
} catch (InterruptedException e) {
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
}
|
314
|
+
|
89
315
|
```
|
90
316
|
|
91
317
|
|
92
318
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
pa
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
i
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
});
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
((Button)findViewById(R.id.button3)).setOnClickListener(new View.OnClickListener() {
|
208
|
-
|
209
|
-
@Override
|
210
|
-
|
211
|
-
public void onClick(View v) {
|
212
|
-
|
213
|
-
new Thread(new Runnable() {
|
214
|
-
|
215
|
-
@Override
|
216
|
-
|
217
|
-
public void run() {
|
218
|
-
|
219
|
-
handler.post(new Runnable() {
|
220
|
-
|
221
|
-
public void run() {
|
222
|
-
|
223
|
-
for(int fa = 0; fa < 10; fa++) {
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
mXWalkView.reload(0);
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
try {//スリープ
|
232
|
-
|
233
|
-
Thread.sleep(30);
|
234
|
-
|
235
|
-
} catch (InterruptedException e) {
|
236
|
-
|
237
|
-
}
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
mXWalkView.stopLoading();
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
try {//スリープ
|
246
|
-
|
247
|
-
Thread.sleep(30);
|
248
|
-
|
249
|
-
} catch (InterruptedException e) {
|
250
|
-
|
251
|
-
}
|
252
|
-
|
253
|
-
}
|
254
|
-
|
255
|
-
}
|
256
|
-
|
257
|
-
});
|
258
|
-
|
259
|
-
}
|
260
|
-
|
261
|
-
}).start();
|
262
|
-
|
263
|
-
}
|
264
|
-
|
265
|
-
});
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
}
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
@Override
|
278
|
-
|
279
|
-
protected void onPause() {
|
280
|
-
|
281
|
-
super.onPause();
|
282
|
-
|
283
|
-
if (mXWalkView != null) {
|
284
|
-
|
285
|
-
mXWalkView.pauseTimers();
|
286
|
-
|
287
|
-
mXWalkView.onHide();
|
288
|
-
|
289
|
-
}
|
290
|
-
|
291
|
-
}
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
@Override
|
296
|
-
|
297
|
-
protected void onResume() {
|
298
|
-
|
299
|
-
super.onResume();
|
300
|
-
|
301
|
-
if (mXWalkView != null) {
|
302
|
-
|
303
|
-
mXWalkView.resumeTimers();
|
304
|
-
|
305
|
-
mXWalkView.onShow();
|
306
|
-
|
307
|
-
}
|
308
|
-
|
309
|
-
}
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
@Override
|
314
|
-
|
315
|
-
protected void onDestroy() {
|
316
|
-
|
317
|
-
super.onDestroy();
|
318
|
-
|
319
|
-
if (mXWalkView != null) {
|
320
|
-
|
321
|
-
mXWalkView.onDestroy();
|
322
|
-
|
323
|
-
}
|
324
|
-
|
325
|
-
}
|
326
|
-
|
327
|
-
}
|
328
|
-
|
329
|
-
|
319
|
+
activity_main.xml
|
320
|
+
|
321
|
+
```xml
|
322
|
+
|
323
|
+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
324
|
+
|
325
|
+
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
326
|
+
|
327
|
+
android:layout_height="match_parent" android:paddingLeft="0dp"
|
328
|
+
|
329
|
+
android:paddingRight="0dp"
|
330
|
+
|
331
|
+
android:paddingTop="0dp"
|
332
|
+
|
333
|
+
android:paddingBottom="0dp" tools:context=".MainActivity">
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
<!-- XWalkViewを追加 -->
|
338
|
+
|
339
|
+
<org.xwalk.core.XWalkView
|
340
|
+
|
341
|
+
android:id="@+id/xwalkWebView"
|
342
|
+
|
343
|
+
android:orientation="vertical"
|
344
|
+
|
345
|
+
android:layout_width="fill_parent"
|
346
|
+
|
347
|
+
android:layout_height="fill_parent"
|
348
|
+
|
349
|
+
android:background="#000000"
|
350
|
+
|
351
|
+
/>
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
<LinearLayout
|
356
|
+
|
357
|
+
android:id="@+id/linearLayout1"
|
358
|
+
|
359
|
+
android:layout_width="match_parent"
|
360
|
+
|
361
|
+
android:layout_height="wrap_content" >
|
362
|
+
|
363
|
+
<Button
|
364
|
+
|
365
|
+
android:id="@+id/button1"
|
366
|
+
|
367
|
+
android:layout_width="wrap_content"
|
368
|
+
|
369
|
+
android:layout_height="wrap_content"
|
370
|
+
|
371
|
+
android:layout_weight="1"
|
372
|
+
|
373
|
+
android:text="更新" />
|
374
|
+
|
375
|
+
<Button
|
376
|
+
|
377
|
+
android:id="@+id/button2"
|
378
|
+
|
379
|
+
android:layout_width="wrap_content"
|
380
|
+
|
381
|
+
android:layout_height="wrap_content"
|
382
|
+
|
383
|
+
android:layout_weight="1"
|
384
|
+
|
385
|
+
android:text="更新中止" />
|
386
|
+
|
387
|
+
<Button
|
388
|
+
|
389
|
+
android:id="@+id/button3"
|
390
|
+
|
391
|
+
android:layout_width="wrap_content"
|
392
|
+
|
393
|
+
android:layout_height="wrap_content"
|
394
|
+
|
395
|
+
android:layout_weight="1"
|
396
|
+
|
397
|
+
android:text="連続更新中止" />
|
398
|
+
|
399
|
+
<Button
|
400
|
+
|
401
|
+
android:id="@+id/button4"
|
402
|
+
|
403
|
+
android:layout_width="wrap_content"
|
404
|
+
|
405
|
+
android:layout_height="wrap_content"
|
406
|
+
|
407
|
+
android:layout_weight="1"
|
408
|
+
|
409
|
+
android:text="none" />
|
410
|
+
|
411
|
+
<Button
|
412
|
+
|
413
|
+
android:id="@+id/button5"
|
414
|
+
|
415
|
+
android:layout_width="wrap_content"
|
416
|
+
|
417
|
+
android:layout_height="wrap_content"
|
418
|
+
|
419
|
+
android:layout_weight="1"
|
420
|
+
|
421
|
+
android:text="none" />
|
422
|
+
|
423
|
+
</LinearLayout>
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
</RelativeLayout>
|
330
428
|
|
331
429
|
```
|
332
430
|
|
333
431
|
|
334
432
|
|
335
|
-
a
|
433
|
+
AndroidManifest.xml
|
336
434
|
|
337
435
|
```xml
|
338
436
|
|
339
|
-
<
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
a
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
android:
|
348
|
-
|
349
|
-
android:
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
<
|
356
|
-
|
357
|
-
android:
|
358
|
-
|
359
|
-
android:
|
360
|
-
|
361
|
-
android:la
|
362
|
-
|
363
|
-
android:
|
364
|
-
|
365
|
-
android:
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
<
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
android:
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
<
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
android:layout_weight="1"
|
388
|
-
|
389
|
-
android:text="更新" />
|
390
|
-
|
391
|
-
<Button
|
392
|
-
|
393
|
-
android:id="@+id/button2"
|
394
|
-
|
395
|
-
android:layout_width="wrap_content"
|
396
|
-
|
397
|
-
android:layout_height="wrap_content"
|
398
|
-
|
399
|
-
android:layout_weight="1"
|
400
|
-
|
401
|
-
android:text="更新中止" />
|
402
|
-
|
403
|
-
<Button
|
404
|
-
|
405
|
-
android:id="@+id/button3"
|
406
|
-
|
407
|
-
android:layout_width="wrap_content"
|
408
|
-
|
409
|
-
android:layout_height="wrap_content"
|
410
|
-
|
411
|
-
android:layout_weight="1"
|
412
|
-
|
413
|
-
android:text="連続更新中止" />
|
414
|
-
|
415
|
-
<Button
|
416
|
-
|
417
|
-
android:id="@+id/button4"
|
418
|
-
|
419
|
-
android:layout_width="wrap_content"
|
420
|
-
|
421
|
-
android:layout_height="wrap_content"
|
422
|
-
|
423
|
-
android:layout_weight="1"
|
424
|
-
|
425
|
-
android:text="更新後中止" />
|
426
|
-
|
427
|
-
<Button
|
428
|
-
|
429
|
-
android:id="@+id/button5"
|
430
|
-
|
431
|
-
android:layout_width="wrap_content"
|
432
|
-
|
433
|
-
android:layout_height="wrap_content"
|
434
|
-
|
435
|
-
android:layout_weight="1"
|
436
|
-
|
437
|
-
android:text="none" />
|
438
|
-
|
439
|
-
</LinearLayout>
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
</RelativeLayout>
|
437
|
+
<?xml version="1.0" encoding="utf-8"?>
|
438
|
+
|
439
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
440
|
+
|
441
|
+
package="パッケージ名">
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
446
|
+
|
447
|
+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
448
|
+
|
449
|
+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
<application
|
454
|
+
|
455
|
+
android:allowBackup="true"
|
456
|
+
|
457
|
+
android:icon="@mipmap/ic_launcher"
|
458
|
+
|
459
|
+
android:label="@string/app_name"
|
460
|
+
|
461
|
+
android:supportsRtl="true"
|
462
|
+
|
463
|
+
android:theme="@style/AppTheme">
|
464
|
+
|
465
|
+
<activity android:name=".MainActivity">
|
466
|
+
|
467
|
+
<intent-filter>
|
468
|
+
|
469
|
+
<action android:name="android.intent.action.MAIN" />
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
<category android:name="android.intent.category.LAUNCHER" />
|
474
|
+
|
475
|
+
</intent-filter>
|
476
|
+
|
477
|
+
</activity>
|
478
|
+
|
479
|
+
</application>
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
</manifest>
|
444
484
|
|
445
485
|
```
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
AndroidManifest.xml
|
450
|
-
|
451
|
-
```xml
|
452
|
-
|
453
|
-
<?xml version="1.0" encoding="utf-8"?>
|
454
|
-
|
455
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
456
|
-
|
457
|
-
package="パッケージ名">
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
<uses-permission android:name="android.permission.INTERNET" />
|
462
|
-
|
463
|
-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
464
|
-
|
465
|
-
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
<application
|
470
|
-
|
471
|
-
android:allowBackup="true"
|
472
|
-
|
473
|
-
android:icon="@mipmap/ic_launcher"
|
474
|
-
|
475
|
-
android:label="@string/app_name"
|
476
|
-
|
477
|
-
android:supportsRtl="true"
|
478
|
-
|
479
|
-
android:theme="@style/AppTheme">
|
480
|
-
|
481
|
-
<activity android:name=".MainActivity">
|
482
|
-
|
483
|
-
<intent-filter>
|
484
|
-
|
485
|
-
<action android:name="android.intent.action.MAIN" />
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
<category android:name="android.intent.category.LAUNCHER" />
|
490
|
-
|
491
|
-
</intent-filter>
|
492
|
-
|
493
|
-
</activity>
|
494
|
-
|
495
|
-
</application>
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
</manifest>
|
500
|
-
|
501
|
-
```
|
2
2016年11月23日に「MainActivity\.java」を更新いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -164,7 +164,7 @@
|
|
164
164
|
|
165
165
|
mXWalkView = (XWalkView) findViewById(R.id.xwalkWebView);
|
166
166
|
|
167
|
-
mXWalkView.load("
|
167
|
+
mXWalkView.load("対象のサイト", null);
|
168
168
|
|
169
169
|
|
170
170
|
|
1
2016年11月23日に「MainActivity\.java」を更新いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
+
2016年11月23日に「MainActivity.java」を更新いたしました。
|
2
|
+
|
3
|
+
|
4
|
+
|
1
5
|
Android Studio 2.1.0.0
|
2
6
|
|
3
7
|
使用端末:HTL22 Androidバージョン:4.1.2
|
4
8
|
|
5
9
|
|
6
10
|
|
11
|
+
|
12
|
+
|
7
13
|
ブラウザアプリの開発をしています。
|
8
14
|
|
9
15
|
|
@@ -20,47 +26,65 @@
|
|
20
26
|
|
21
27
|
```java
|
22
28
|
|
23
|
-
((Button)findViewById(R.id.button3)).setOnClickListener(new View.OnClickListener() {
|
29
|
+
((Button)findViewById(R.id.button3)).setOnClickListener(new View.OnClickListener() {
|
24
|
-
|
30
|
+
|
25
|
-
|
31
|
+
@Override
|
26
|
-
|
32
|
+
|
27
|
-
|
33
|
+
public void onClick(View v) {
|
34
|
+
|
28
|
-
|
35
|
+
new Thread(new Runnable() {
|
36
|
+
|
37
|
+
@Override
|
38
|
+
|
39
|
+
public void run() {
|
40
|
+
|
41
|
+
handler.post(new Runnable() {
|
42
|
+
|
43
|
+
public void run() {
|
44
|
+
|
29
|
-
|
45
|
+
for(int fa = 0; fa < 10; fa++) {
|
30
|
-
|
46
|
+
|
47
|
+
|
48
|
+
|
31
|
-
|
49
|
+
mXWalkView.reload(0);
|
32
|
-
|
33
|
-
|
34
|
-
|
50
|
+
|
51
|
+
|
52
|
+
|
35
|
-
|
53
|
+
try {//スリープ
|
36
|
-
|
54
|
+
|
37
|
-
|
55
|
+
Thread.sleep(30);
|
38
|
-
|
56
|
+
|
39
|
-
|
57
|
+
} catch (InterruptedException e) {
|
40
|
-
|
58
|
+
|
41
|
-
|
59
|
+
}
|
42
|
-
|
43
|
-
|
44
|
-
|
60
|
+
|
61
|
+
|
62
|
+
|
45
|
-
|
63
|
+
mXWalkView.stopLoading();
|
46
|
-
|
47
|
-
|
48
|
-
|
64
|
+
|
65
|
+
|
66
|
+
|
49
|
-
|
67
|
+
try {//スリープ
|
50
|
-
|
68
|
+
|
51
|
-
|
69
|
+
Thread.sleep(30);
|
52
|
-
|
70
|
+
|
53
|
-
|
71
|
+
} catch (InterruptedException e) {
|
54
|
-
|
72
|
+
|
55
|
-
|
73
|
+
}
|
56
|
-
|
57
|
-
|
58
|
-
|
74
|
+
|
59
|
-
|
75
|
+
}
|
60
|
-
|
76
|
+
|
61
|
-
|
77
|
+
}
|
62
|
-
|
78
|
+
|
63
|
-
});
|
79
|
+
});
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
}).start();
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
});
|
64
88
|
|
65
89
|
```
|
66
90
|
|
@@ -78,6 +102,10 @@
|
|
78
102
|
|
79
103
|
|
80
104
|
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
81
109
|
以下に、動作確認をした際の「MainActivity.java」「activity_main.xml」「AndroidManifest.xml」の内容を示します。
|
82
110
|
|
83
111
|
ご参照いただけますと幸いです。
|
@@ -104,6 +132,10 @@
|
|
104
132
|
|
105
133
|
import org.xwalk.core.internal.XWalkCookieManager;
|
106
134
|
|
135
|
+
import android.os.Bundle;
|
136
|
+
|
137
|
+
import android.os.Handler;
|
138
|
+
|
107
139
|
|
108
140
|
|
109
141
|
public class MainActivity extends ActionBarActivity {
|
@@ -116,6 +148,10 @@
|
|
116
148
|
|
117
149
|
|
118
150
|
|
151
|
+
Handler handler = new Handler();
|
152
|
+
|
153
|
+
|
154
|
+
|
119
155
|
@Override
|
120
156
|
|
121
157
|
protected void onCreate(Bundle savedInstanceState) {
|
@@ -128,7 +164,7 @@
|
|
128
164
|
|
129
165
|
mXWalkView = (XWalkView) findViewById(R.id.xwalkWebView);
|
130
166
|
|
131
|
-
mXWalkView.load("
|
167
|
+
mXWalkView.load("https://sdx.co.jp/member/login/index.do", null);
|
132
168
|
|
133
169
|
|
134
170
|
|
@@ -174,44 +210,70 @@
|
|
174
210
|
|
175
211
|
public void onClick(View v) {
|
176
212
|
|
213
|
+
new Thread(new Runnable() {
|
214
|
+
|
215
|
+
@Override
|
216
|
+
|
217
|
+
public void run() {
|
218
|
+
|
219
|
+
handler.post(new Runnable() {
|
220
|
+
|
221
|
+
public void run() {
|
222
|
+
|
177
|
-
for(int fa = 0; fa < 10; fa++) {
|
223
|
+
for(int fa = 0; fa < 10; fa++) {
|
178
|
-
|
224
|
+
|
225
|
+
|
226
|
+
|
179
|
-
mXWalkView.reload(0);
|
227
|
+
mXWalkView.reload(0);
|
180
|
-
|
181
|
-
|
182
|
-
|
228
|
+
|
229
|
+
|
230
|
+
|
183
|
-
try {//スリープ
|
231
|
+
try {//スリープ
|
184
|
-
|
232
|
+
|
185
|
-
Thread.sleep(
|
233
|
+
Thread.sleep(30);
|
186
|
-
|
234
|
+
|
187
|
-
} catch (InterruptedException e) {
|
235
|
+
} catch (InterruptedException e) {
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
mXWalkView.stopLoading();
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
try {//スリープ
|
246
|
+
|
247
|
+
Thread.sleep(30);
|
248
|
+
|
249
|
+
} catch (InterruptedException e) {
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
});
|
188
258
|
|
189
259
|
}
|
190
260
|
|
191
|
-
|
192
|
-
|
193
|
-
mXWalkView.stopLoading();
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
try {//スリープ
|
198
|
-
|
199
|
-
|
261
|
+
}).start();
|
200
|
-
|
201
|
-
} catch (InterruptedException e) {
|
202
|
-
|
203
|
-
}
|
204
|
-
|
205
|
-
}
|
206
262
|
|
207
263
|
}
|
208
264
|
|
209
265
|
});
|
210
266
|
|
267
|
+
|
268
|
+
|
211
269
|
}
|
212
270
|
|
213
271
|
|
214
272
|
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
215
277
|
@Override
|
216
278
|
|
217
279
|
protected void onPause() {
|
@@ -264,6 +326,8 @@
|
|
264
326
|
|
265
327
|
}
|
266
328
|
|
329
|
+
|
330
|
+
|
267
331
|
```
|
268
332
|
|
269
333
|
|