public class GCMIntentService extends GCMBaseIntentService {
public static final String PROJECT_ID = "4898989797";
private static final String TAG = "GCMIntentService";
ModelNotificationMessage modelNotificationMessage;
public GCMIntentService() {
super(PROJECT_ID);
Log.d(TAG, "GCMIntentService init");
}
@Override
protected void onError(Context ctx, String sError) {
// TODO Auto-generated method stub
Log.d(TAG, "Error: " + sError);
}
@Override
protected void onMessage(Context ctx, Intent intent) {
Log.d(TAG, "Message Received");
String message = intent.getStringExtra("message");
Log.d(TAG, "Message Received" + message);
sendNotification(message);
Intent broadcastIntent = new Intent();
broadcastIntent.setAction("GCM_RECEIVED_ACTION");
broadcastIntent.putExtra("gcm", message);
ctx.sendBroadcast(broadcastIntent);
}
private void sendNotification(String message) {
// this
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.notification;
CharSequence tickerText = message; // ticker-text
long when = System.currentTimeMillis();
Context context = getApplicationContext();
CharSequence contentTitle = modelNotificationMessage.getKey();
CharSequence contentText = message;
Intent notificationIntent = null;
int NOTIFICATION_ID = 9999;
NOTIFICATION_ID = CommonVariable.notification_message;
notificationIntent = new Intent(this, ViewMessages.class);
contentText = arrayList.get(0).getDescription();
tickerText = arrayList.get(0).getDescription();
// and this
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
Notification notification = new Notification(icon, tickerText, when);
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
notification.setLatestEventInfo(context, contentTitle, contentText,
contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, notification);
}
你在说如何制作Android TABLET风格的状态栏吗? – Robin
没有。 。 。看看你的手机。 。 。你一直在电话右侧看到wifi信号和电话信号。我希望我的信号在那里显示。 。 。以及系统信号。 。我公司生产的平板电脑中有一个新的硬件芯片,并且可以像电话信号一样持续显示其信号强度。它将被整合到android源代码中。 –
这么多意见和没有答案。 。 。有人可以投票的问题,让人们觉得有必要回答吗?或者赏金事情如何工作? –