質問編集履歴
2
アラーム鳴動用のソース(スクリーンロック解除部分)及びアプリのManifestを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -242,16 +242,6 @@
|
|
242
242
|
|
243
243
|
.setCategory(NotificationCompat.CATEGORY_ALARM)
|
244
244
|
|
245
|
-
// Use a full-screen intent only for the highest-priority alerts where you
|
246
|
-
|
247
|
-
// have an associated activity that you would like to launch after the user
|
248
|
-
|
249
|
-
// interacts with the notification. Also, if your app targets Android 10
|
250
|
-
|
251
|
-
// or higher, you need to request the USE_FULL_SCREEN_INTENT permission in
|
252
|
-
|
253
|
-
// order for the platform to invoke this notification.
|
254
|
-
|
255
245
|
.setFullScreenIntent(fullScreenPendingIntent, true);
|
256
246
|
|
257
247
|
|
@@ -320,20 +310,12 @@
|
|
320
310
|
|
321
311
|
CHANNEL_ID,
|
322
312
|
|
323
|
-
|
324
|
-
|
325
313
|
// 設定に表示されるチャンネル名
|
326
314
|
|
327
|
-
// ここは実際にはリソースを指定するのが良さそう
|
328
|
-
|
329
315
|
CHANNEL_NAME,
|
330
316
|
|
331
|
-
|
332
|
-
|
333
317
|
// チャンネルの重要度
|
334
318
|
|
335
|
-
// 重要度によって表示箇所が異なる
|
336
|
-
|
337
319
|
NotificationManager.IMPORTANCE_DEFAULT
|
338
320
|
|
339
321
|
);
|
@@ -395,3 +377,171 @@
|
|
395
377
|
}
|
396
378
|
|
397
379
|
```
|
380
|
+
|
381
|
+
####アラームのアクティビティ(画面立ち上げ部分とアラーム部分 他は長いため省略)
|
382
|
+
|
383
|
+
Alarm_vib.java
|
384
|
+
|
385
|
+
```java
|
386
|
+
|
387
|
+
@Override
|
388
|
+
|
389
|
+
protected void onCreate(Bundle savedInstanceState) {
|
390
|
+
|
391
|
+
super.onCreate(savedInstanceState);
|
392
|
+
|
393
|
+
setContentView(R.layout.vib_layout);
|
394
|
+
|
395
|
+
//スリープの解除
|
396
|
+
|
397
|
+
wakeFromSleep();
|
398
|
+
|
399
|
+
/*
|
400
|
+
|
401
|
+
省略
|
402
|
+
|
403
|
+
*/
|
404
|
+
|
405
|
+
//アラームの再セット
|
406
|
+
|
407
|
+
Alarm_set();
|
408
|
+
|
409
|
+
//バイブの起動
|
410
|
+
|
411
|
+
VibeOn();
|
412
|
+
|
413
|
+
}
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
//スリープ解除関数
|
418
|
+
|
419
|
+
private void wakeFromSleep() {
|
420
|
+
|
421
|
+
// Lock解除画面より手前に表示させる
|
422
|
+
|
423
|
+
final Window win = getWindow();
|
424
|
+
|
425
|
+
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
426
|
+
|
427
|
+
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
wakelock = ((PowerManager) getSystemService(android.content.Context.POWER_SERVICE))
|
432
|
+
|
433
|
+
.newWakeLock(PowerManager.FULL_WAKE_LOCK
|
434
|
+
|
435
|
+
| PowerManager.ACQUIRE_CAUSES_WAKEUP
|
436
|
+
|
437
|
+
| PowerManager.ON_AFTER_RELEASE, "vib:disableLock");
|
438
|
+
|
439
|
+
wakelock.acquire();
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
wakelock.release();
|
444
|
+
|
445
|
+
//ロック解除
|
446
|
+
|
447
|
+
KeyguardManager keyguard = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
|
448
|
+
|
449
|
+
keylock = keyguard.newKeyguardLock("disableLock");
|
450
|
+
|
451
|
+
keylock.disableKeyguard();
|
452
|
+
|
453
|
+
}
|
454
|
+
|
455
|
+
```
|
456
|
+
|
457
|
+
####アプリのManifest(長いので一部省略)
|
458
|
+
|
459
|
+
```xml
|
460
|
+
|
461
|
+
<?xml version="1.0" encoding="utf-8"?>
|
462
|
+
|
463
|
+
<manifest>
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
<!--パーミッション-->
|
468
|
+
|
469
|
+
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
470
|
+
|
471
|
+
<uses-permission android:name="android.permission.VIBRATE" />
|
472
|
+
|
473
|
+
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
474
|
+
|
475
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
476
|
+
|
477
|
+
<!--アプリ-->
|
478
|
+
|
479
|
+
<application
|
480
|
+
|
481
|
+
android:name=".MyApplication"
|
482
|
+
|
483
|
+
android:allowBackup="true"
|
484
|
+
|
485
|
+
android:icon="@mipmap/ic_launcher"
|
486
|
+
|
487
|
+
android:label="@string/app_name"
|
488
|
+
|
489
|
+
android:roundIcon="@mipmap/ic_launcher_round"
|
490
|
+
|
491
|
+
android:supportsRtl="true"
|
492
|
+
|
493
|
+
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
<!--一部省略-->
|
502
|
+
|
503
|
+
<!--アラーム鳴動用-->
|
504
|
+
|
505
|
+
<activity android:name=".Alarm_vib">
|
506
|
+
|
507
|
+
<intent-filter>
|
508
|
+
|
509
|
+
<action android:name="android.intent.action.MAIN" />
|
510
|
+
|
511
|
+
<category android:name="android.intent.category.DEFAULT" />
|
512
|
+
|
513
|
+
</intent-filter>
|
514
|
+
|
515
|
+
</activity>
|
516
|
+
|
517
|
+
<!--時間になった時の受け取り-->
|
518
|
+
|
519
|
+
<receiver
|
520
|
+
|
521
|
+
android:name=".AlarmBroadcastReceiver"
|
522
|
+
|
523
|
+
android:process=":remote">
|
524
|
+
|
525
|
+
<intent-filter>
|
526
|
+
|
527
|
+
<category android:name="android.intent.category.DEFAULT" />
|
528
|
+
|
529
|
+
</intent-filter>
|
530
|
+
|
531
|
+
</receiver>
|
532
|
+
|
533
|
+
<!--サービス起動用-->
|
534
|
+
|
535
|
+
<service android:name=".StartVibeService" />
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
<!--一部省略-->
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
</application>
|
544
|
+
|
545
|
+
</manifest>
|
546
|
+
|
547
|
+
```
|
1
参考欄のアプリを追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,7 +46,9 @@
|
|
46
46
|
|
47
47
|
ロックが設定されているandroid10の機種でもロック画面の上にActivityを表示できるアラーム系アプリ
|
48
48
|
|
49
|
-
[アラームアプリ](https://play.google.com/store/apps/details?id=jp.tanyu.SmartAlarmFree&hl=en_US)
|
49
|
+
[アラームアプリ1](https://play.google.com/store/apps/details?id=jp.tanyu.SmartAlarmFree&hl=en_US)
|
50
|
+
|
51
|
+
[アラームアプリ2](https://play.google.com/store/apps/details?id=hdesign.theclock)
|
50
52
|
|
51
53
|
|
52
54
|
|