質問編集履歴
3
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -255,3 +255,87 @@
|
|
255
255
|
|
256
256
|
|
257
257
|
```
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
追記2コンパイルが通ったMainActivity.csです。
|
262
|
+
|
263
|
+
```
|
264
|
+
|
265
|
+
using Android.App;
|
266
|
+
|
267
|
+
using Android.Widget;
|
268
|
+
|
269
|
+
using Android.Content;
|
270
|
+
|
271
|
+
using Android.OS;
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
namespace App8
|
278
|
+
|
279
|
+
{
|
280
|
+
|
281
|
+
[Activity(Label = "App8", MainLauncher = true)]
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
public class MainActivity : Activity
|
286
|
+
|
287
|
+
{
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
protected override void OnCreate(Bundle bundle)
|
292
|
+
|
293
|
+
{
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
base.OnCreate(bundle);
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
// Set our view from the "main" layout resource
|
302
|
+
|
303
|
+
SetContentView(Resource.Layout.Main);
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
Button btnM = FindViewById<Button>(Resource.Id.btnSayHello);
|
308
|
+
|
309
|
+
TextView txtV = FindViewById<TextView>(Resource.Id.txtMsg);
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
ActivityManager am = GetSystemService(Context.ActivityService) as ActivityManager;
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
btnM.Click += delegate
|
320
|
+
|
321
|
+
{
|
322
|
+
|
323
|
+
am.KillBackgroundProcesses("co.offtime.lifestyle.core.blocker.BlockerService");
|
324
|
+
|
325
|
+
};
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
}
|
332
|
+
|
333
|
+
}
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
```
|
2
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -181,3 +181,77 @@
|
|
181
181
|
|
182
182
|
|
183
183
|
KillBackgroundProcesses (String packageName)を動作させるのに正しい手順を教えていただけませんか。
|
184
|
+
|
185
|
+
追記1
|
186
|
+
|
187
|
+
MainActivity.cs
|
188
|
+
|
189
|
+
```
|
190
|
+
|
191
|
+
using Android.App;
|
192
|
+
|
193
|
+
using Android.Widget;
|
194
|
+
|
195
|
+
using Android.Content;
|
196
|
+
|
197
|
+
using Android.OS;
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
namespace App8
|
204
|
+
|
205
|
+
{
|
206
|
+
|
207
|
+
[Activity(Label = "App8", MainLauncher = true)]
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
public class MainActivity : Activity
|
212
|
+
|
213
|
+
{
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
protected override void OnCreate(Bundle bundle)
|
218
|
+
|
219
|
+
{
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
base.OnCreate(bundle);
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
// Set our view from the "main" layout resource
|
228
|
+
|
229
|
+
SetContentView(Resource.Layout.Main);
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
Button btnM = FindViewById<Button>(Resource.Id.btnSayHello);
|
234
|
+
|
235
|
+
TextView txtV = FindViewById<TextView>(Resource.Id.txtMsg);
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
ActivityManager am = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
|
240
|
+
|
241
|
+
am.KillBackgroundProcesses("co.offtime.jp");
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
```
|
1
質問内容修正つけくわえ
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
権限については添付先のサイトには載ってなかったので、
|
24
24
|
|
25
|
-
しらべたらたぶん
|
25
|
+
しらべたらたぶん
|
26
26
|
|
27
27
|
```
|
28
28
|
|
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
```
|
34
34
|
|
35
|
-
これかと思い(どのサイトで
|
35
|
+
これかと思い(どのサイトでとってきたのか忘れました。すいません)
|
36
36
|
|
37
37
|
このコードをAndroid.Manifest.xmlに追加しました。
|
38
38
|
|
@@ -62,6 +62,8 @@
|
|
62
62
|
|
63
63
|
```
|
64
64
|
|
65
|
+
メインのプログラムです。
|
66
|
+
|
65
67
|
MainActivity.csは以下の通りです。
|
66
68
|
|
67
69
|
```C#
|
@@ -80,7 +82,11 @@
|
|
80
82
|
|
81
83
|
{
|
82
84
|
|
85
|
+
|
86
|
+
|
83
87
|
[Activity(Label = "offtimeoff", MainLauncher = true)]
|
88
|
+
|
89
|
+
[Android.Runtime.Register("killBackgroundProcesses", "(Ljava/lang/String;)V", "GetKillBackgroundProcesses_Ljava_lang_String_Handler")]
|
84
90
|
|
85
91
|
|
86
92
|
|
@@ -146,4 +152,32 @@
|
|
146
152
|
|
147
153
|
アセンブリのMono.Androidも追加されていたのですが、エラーが解除されません。
|
148
154
|
|
155
|
+
|
156
|
+
|
157
|
+
コード元サイトに書いてある
|
158
|
+
|
159
|
+
```
|
160
|
+
|
161
|
+
[Android.Runtime.Register("killBackgroundProcesses", "(Ljava/lang/String;)V", "GetKillBackgroundProcesses_Ljava_lang_String_Handler")]
|
162
|
+
|
163
|
+
```
|
164
|
+
|
165
|
+
ですが、とりあえずわからないので
|
166
|
+
|
167
|
+
冒頭の
|
168
|
+
|
169
|
+
```
|
170
|
+
|
171
|
+
[Activity(Label = "offtimeoff", MainLauncher = true)]
|
172
|
+
|
173
|
+
```
|
174
|
+
|
175
|
+
に似ているような気がしたので、上のように並べて記述しました。
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
149
183
|
KillBackgroundProcesses (String packageName)を動作させるのに正しい手順を教えていただけませんか。
|