所以我的 Android 应用程序使用 GCM 推送通知并实现唤醒服务来格式化传入通知。我正在为通知实现相应的头像图像,但图像是使用 REST 从我们的服务器中提取的。
我的问题 - 如果应用程序不在前台(在待机模式下关闭或禁用),那么我无法连接以检索头像资源。我已经从这里实现了我的代码:https ://developer.android.com/google/gcm/client.html (在“接收消息”下)。
问题 - 如何重新启动已关闭的应用程序以便检索头像以添加到 GCM 通知?
这是我创建通知时的片段:
RestApi restApi = RestApi.getInstance(this);
senderAvatarUrl = restApi.MyAppAvatarThumbnailUrl(id);
bitmap = getBitmapFromURL(senderAvatarUrl);
if (bitmap == null){
bitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.placeholder_avatar);
}
bitmap = getCroppedBitmap(bitmap);
mBuilder= new NotificationCompat.Builder(this).setAutoCancel(true)
.setSmallIcon(R.drawable.fourth_notification)
.setLargeIcon(bitmap)
.setContentTitle(nameShouldBe)
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setLights(Color.GREEN, 100, 10000)
.setContentText(msg);
mBuilder.build();
谢谢