回答編集履歴
1
ソースコードを記述
test
CHANGED
@@ -1 +1,69 @@
|
|
1
1
|
自己解決しました、ソースコードに変更した点を書き込んでおきます。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
```
|
6
|
+
|
7
|
+
override fun onReceive(context: Context?, intent: Intent?) {
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
/ここから
|
12
|
+
|
13
|
+
val action = intent?.action
|
14
|
+
|
15
|
+
if (action.equals("android.intent.action.TIME_TICK")) {
|
16
|
+
|
17
|
+
Log.i(ContentValues.TAG,"TIME_TICK-LOG");
|
18
|
+
|
19
|
+
}
|
20
|
+
|
21
|
+
/ここまで削除
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
super.onReceive(context, intent)
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
```
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
```updateAppWidgetを編集
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
internal fun updateAppWidget(
|
38
|
+
|
39
|
+
context: Context,
|
40
|
+
|
41
|
+
appWidgetManager: AppWidgetManager,
|
42
|
+
|
43
|
+
appWidgetId: Int
|
44
|
+
|
45
|
+
) {
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
val br: BroadcastReceiver = TestClockWidget()
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
val filter = IntentFilter(Intent.ACTION_TIME_TICK)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
context.getApplicationContext().registerReceiver(br, filter)
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
val views = RemoteViews(context.packageName, R.layout.test_clock_widget)
|
62
|
+
|
63
|
+
appWidgetManager.updateAppWidget(appWidgetId, views)
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
```
|