質問編集履歴
4
修正依頼を受けての修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -27,3 +27,115 @@
|
|
27
27
|
※下記のサイトでは【AndroidStudio】を使ったライブラリのインポートが書かれていたのですが、うまく行きませんでした。
|
28
28
|
|
29
29
|
http://documentation.kii.com/ja/samples/push-notifications/push-notifications-android/configure-eclipse/
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
###発生している問題・エラーメッセージ
|
34
|
+
|
35
|
+
下記のソースを書いたのですが、GoogleCloudMessaging と書いたところが、赤くなり、要約すると「新しいクラスを作りなさい。」と言うようなエラー出てしまいます。正しく、ライブラリーがインポートされているなら、Alt + Enter でクラスを読み込んでくれると思うので、ライブラリーが正しくインポート出来ていないのかと思いました。
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
###ソースコード
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
package sns.sysxxx.net.snsapp;
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
import android.app.IntentService;
|
48
|
+
|
49
|
+
import android.content.Intent;
|
50
|
+
|
51
|
+
import android.os.Bundle;
|
52
|
+
|
53
|
+
import android.util.Log;
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
public class GcmIntentService extends IntentService {
|
58
|
+
|
59
|
+
private static final String TAG = "GcmIntentService";
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
// 引数なしのコンストラクタを作成しないと例外で落ちてしまった
|
64
|
+
|
65
|
+
public GcmIntentService() {
|
66
|
+
|
67
|
+
super(GcmIntentService.class.getName());
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
public GcmIntentService(String name) {
|
74
|
+
|
75
|
+
super(name);
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
@Override
|
82
|
+
|
83
|
+
protected void onHandleIntent(Intent intent) {
|
84
|
+
|
85
|
+
Bundle extras = intent.getExtras();
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
// intentからGCMのメッセージを取得する
|
90
|
+
|
91
|
+
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
|
92
|
+
|
93
|
+
String messageType = gcm.getMessageType(intent);
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
// GCMのメッセージをタイプ別にフィルタリングする。
|
98
|
+
|
99
|
+
// 将来的に拡張されることを考慮し、存在しないタイプを無視するようにする
|
100
|
+
|
101
|
+
if (!extras.isEmpty()) {
|
102
|
+
|
103
|
+
if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
|
104
|
+
|
105
|
+
// エラー
|
106
|
+
|
107
|
+
Log.d(TAG, "messageType: " + messageType + ",send error:" + extras.toString());
|
108
|
+
|
109
|
+
} else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
|
110
|
+
|
111
|
+
// サーバー側でメッセージを削除された
|
112
|
+
|
113
|
+
Log.d(TAG,"messageType: " + messageType + ",message deleted:" + extras.toString());
|
114
|
+
|
115
|
+
} else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
|
116
|
+
|
117
|
+
// メッセージ受信
|
118
|
+
|
119
|
+
Log.d(TAG,"messageType: " + messageType + ",received message:" + extras.toString());
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
// 処理の終了をReceiverに通知し、ロックを解放する
|
126
|
+
|
127
|
+
GcmBroadcastReceiver.completeWakefulIntent(intent);
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
```
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
###補足情報(言語/FW/ツール等のバージョンなど)
|
140
|
+
|
141
|
+
AndroidStudio 1.2.2 を使っています。
|
3
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,12 +18,12 @@
|
|
18
18
|
|
19
19
|
↓
|
20
20
|
|
21
|
-
インストールされたら、ライブラリをインポート ← これに付いては、
|
21
|
+
インストールされたら、ライブラリをインポート ← これに付いては、【Eclipse】の方法と違っているようで、【AndroidStudio】に、ライブラリをインポート出来ません。
|
22
22
|
|
23
23
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
-
※下記のサイトでは【AndroidStudio】を使ったライブラリ
|
27
|
+
※下記のサイトでは【AndroidStudio】を使ったライブラリのインポートが書かれていたのですが、うまく行きませんでした。
|
28
28
|
|
29
29
|
http://documentation.kii.com/ja/samples/push-notifications/push-notifications-android/configure-eclipse/
|
2
文法修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -27,7 +27,3 @@
|
|
27
27
|
※下記のサイトでは【AndroidStudio】を使ったライブラリをインポートが書かれていたのですが、うまく行きませんでした。
|
28
28
|
|
29
29
|
http://documentation.kii.com/ja/samples/push-notifications/push-notifications-android/configure-eclipse/
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
###
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
↓
|
20
20
|
|
21
|
-
インストールされたら、ライブラリをインポート ← これに付いては、、【Eclipse】の方法と違っているようで、【AndroidStudio】ライブラリをインポート出来ません。
|
21
|
+
インストールされたら、ライブラリをインポート ← これに付いては、、【Eclipse】の方法と違っているようで、【AndroidStudio】に、ライブラリをインポート出来ません。
|
22
22
|
|
23
23
|
|
24
24
|
|