Integer id_user = 1;
Intent registration= new Intent("com.google.android.c2dm.intent.REGISTER");
registration.putExtra("app", PendingIntent.getBroadcast(getBaseContext(),0,new Intent(),0));
registration.putExtra("sender",project_number);
startService(registration);
我需要加上类似的
registration.putExtra(" id_user",id_user);
并收到广泛的
public class resquest extends BroadcastReceiver {
NEED CATCH HERE..... a USER_ID
@Override
public void onReceive(Context context, Intent intent) {
.....Code here
}
}
问候!
答案 0 :(得分:0)
首先,您需要发送用户ID才能获取它:
Integer id_user = 1;
Intent registration= new Intent("com.google.android.c2dm.intent.REGISTER");
registration.putExtra("app", PendingIntent.getBroadcast(getBaseContext(),0,new Intent(),0));
registration.putExtra("sender",project_number);
registration.putExtra("id_user", id_user.intValue());
startService(registration);
然后你可以像这样获取它
public class resquest extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
int id_user = i.getExtras().getInt("id_user");
}
}