活动未获得正确的捆绑

红段

我正在使用GCM,这是我的onMessage函数:

@Override
protected void onMessage(Context context, Intent intent) {
    if (intent != null && intent.getExtras() != null) {
        try {
            String message = intent.getExtras().getString("message");
            String userId = intent.getExtras().getString("user_id");
            Log.i("","postda user id is:" + userId);
            Log.i("","will enter here FRIENDS: ");
            generateNotification(context, message, userId);
        } catch (Exception e) {
            Utils.appendLog("onMessage errror : " + e.getMessage());
            Log.i(TAG, e.getMessage(), e);
        }
    }
}

这是我的CreateNotification函数:

private static void generateNotification(Context context, String message, String userID) {
    Log.i("", "postda user message " + message + ".... userid: " + userID);
    String title = context.getString(R.string.passenger_name);
    Intent notificationIntent = new Intent(context, PSProfileActivity.class);
    notificationIntent.putExtra("id", userID);
    Log.i("", "postda ---------- userid: "+ userID);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP| Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
    Log.i("", "postda message: " + message + "....userID " + userID );

    PSLocationCenter.getInstance().pref.setDataChanged(context, true);
    PSLocationCenter.getInstance().pref.setDataChangedProfile(context, true);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
    mBuilder.setContentTitle(title).setContentText(message).setSmallIcon(R.drawable.notification_icon);
    mBuilder.setContentIntent(intent);
    Notification notification = mBuilder.build();
    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(1, notification);

    playTone(context);
}

这是PSProfileActivity onCreate函数:

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);
    ButterKnife.inject(this);

    mHeader = new ProfileHeader(this, backFromHeader);
    mData = new ProfileData(this);
    mButtons = new ProfileViewPagerButtons(PSProfileActivity.this, firstPage);

    Bundle bundle = getIntent().getExtras();
    if(bundle != null) id = bundle.getString("id");
    Log.i("", "postda in profile id is:" + id);
    if(!id.contentEquals(String.valueOf(PSLocationCenter.getInstance().pref.getUserId(PSProfileActivity.this)))){
        findViewById(R.id.action_settings).setVisibility(View.INVISIBLE);
    }
    Log.i("", "postda in profile id is 2:" + id);
}

这是我的Logcat回应:

04-17 15:33:53.650   9699-11695/nl.hgrams.passenger I/﹕ postda user id is:23
04-17 15:33:53.651   9699-11695/nl.hgrams.passenger I/﹕ postda user message alin reddd accepted your friend request..... userid: 23
04-17 15:33:53.651   9699-11695/nl.hgrams.passenger I/﹕ postda ---------- userid: 23
04-17 15:33:53.652   9699-11695/nl.hgrams.passenger I/﹕ postda message: alin reddd accepted your friend request.....userID 23
04-17 15:33:58.812    9699-9699/nl.hgrams.passenger I/﹕ postda in profile id is:28
04-17 15:33:58.814    9699-9699/nl.hgrams.passenger I/﹕ postda in profile id is 2:28

如您所见,我正在通过分发包发送一个ID,但是我在另一页上获得的ID是一个完全不同的ID(实际上是应该在此处获得的最后一个ID)。这真的很奇怪,有人知道为什么会这样吗?

绿色妖精

在中使用唯一标识PendingIntent

int iUniqueId = (int) (System.currentTimeMillis() & 0xfffffff);      
PendingIntent.getActivity(context, iUniqueId, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

活动未获得正确的捆绑

来自分类Dev

Angular Dropdown所选项目未获得正确的值

来自分类Dev

MVC控制器未获得正确的参数值

来自分类Dev

Python-点类未获得正确的输出

来自分类Dev

TimeSpan未获得正确的剩余时间

来自分类Dev

数组输入周期未获得正确的值

来自分类Dev

在Yaml模板中未获得正确的输出

来自分类Dev

在JTable中搜索-未获得正确的输出

来自分类Dev

片段未获得正确的控制器

来自分类Dev

从文件读取的文件名未获得正确的值

来自分类Dev

在横向方向上未获得正确的UILabel大小

来自分类Dev

附加内容未获得正确的CSS样式

来自分类Dev

从主机到设备的 PyCUDA 值未获得正确值

来自分类Dev

未获得细分错误

来自分类Dev

Linq-to-SQL dbml DateTimeOffset列自动生成的值未获得正确的时区

来自分类Dev

使用simplecursoradapter的自定义实现未获得正确的数据

来自分类Dev

Linq-to-SQL dbml DateTimeOffset列自动生成的值未获得正确的时区

来自分类Dev

使用Mongoose的Node.js中的MongoDB聚合未获得正确的结果

来自分类Dev

在数组位置移动值时未获得正确的输出

来自分类Dev

Kubernetes系统容器“暂停”未获得正确的端口映射

来自分类Dev

使用queryProcessInstancesCount方法调用时,Camunda BPM中未获得正确的值

来自分类Dev

JavaScript正在提交一个简单的请求,但未获得正确的反馈

来自分类Dev

加急审核仍未获得批准

来自分类Dev

线程条件变量:未获得的锁

来自分类Dev

RowId在jqGrid中未获得SET

来自分类Dev

错误:未获得所需的输出

来自分类Dev

UISearchController搜索栏未获得焦点

来自分类Dev

youtube搜索未获得网址

来自分类Dev

.bash_profile未获得

Related 相关文章

热门标签

归档