我正在显示附加到我的项目的库的通知,当点击通知时,通知将转到活动(ReceivingActivity).单击通知后,活动将打开,但不会收到附加到其中的附加内容.
通知触发代码 - sendNotification当我收到gcm消息并且通知代码在库中时我打电话
public static final int NOTIFICATION_ID = 1;
private NotificationManager mNotificationManager;
NotificationCompat.Builder builder;
private void sendNotification(Bundle extras) {
mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
Intent redirectIntent = new Intent(this, Class.forName("com.xyz.kljdf.ReceivingActivity"));
redirectIntent.putExtra("key", "value"); // These extras are not received in ReceivingActivity onCreate(), see the code below
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
redirectIntent, 0);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(((Context)this).getResources().getIdentifier("icon", "drawable", getPackageName()))
.setContentTitle(extras.getString(PushConstants.TITLE))
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(extras.getString(PushConstants.ALERT)))
.setContentText(extras.getString(PushConstants.ALERT));
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
Run Code Online (Sandbox Code Playgroud)
检查ReceivingActivity中的附加内容......
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_receiving);
Log.i("extras..... …Run Code Online (Sandbox Code Playgroud) 我只是用C语言编写了一个使用命令行参数的程序,然后尝试打印第一个参数。当我使用以下命令执行程序时
./a.out $23
Run Code Online (Sandbox Code Playgroud)
并尝试使用下面的代码打印第一个参数
printf("%s", argv[1]);
Run Code Online (Sandbox Code Playgroud)
输出是
3
Run Code Online (Sandbox Code Playgroud)
我是否在这里缺少某些内容,如果存在某些特殊字符,则对命令行参数的处理会有所不同。有人可以解释这种行为。
我正在尝试创建一个聊天应用程序.通信基于RESTful Web服务(Jersey).客户端与发送HTTP请求的服务器通信.我的问题是如何在没有客户端首先发送请求的情况下将消息从服务器发送到客户端.我读到了有关C2DM通知的信息,我想用这种方式,当客户端从服务器收到通知时(客户端)必须向服务器发送请求才能接收数据.我也在考虑使用套接字,但我不知道是否可以使用Rest.我的意思是在服务器端,我还可以使用REST代码的套接字(在较低级别运行的套接字)吗?我唯一可以使用套接字工作的是创建另一个带套接字的服务器(两个服务器RESTful和socket),但这是一个很好的解决方案吗?我也可以在客户端放置一些服务器代码,在服务器端放置一些客户端代码.这是正确有效的吗?你怎么看?哪种解决方案最好?
我的Android应用程序大小在设备上只有5MB,但是当我运行应用程序时,它使用了大量的内存,大约12-18 MB(以及更多的ics设备).我试图找到一个解释,为什么我的应用程序使用大量的RAM,我也使用解析推送服务.我的应用程序是图像密集型,可能是一个可能的原因.如何减少应用程序的RAM消耗.