我需要将一个字符串数组从 AlarmReceiver.class 传递给 Notify.class,但该字符串始终为“null”。现在,AlarmReceiver 中的意图有问题吗?
public class AlarmReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
[...]
Intent notificationIntent = new Intent("com.example.myapp", null, context, Notify.class);
notificationIntent.putExtra("notify", not1[x]);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
通知班级:
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Intent notificationIntent = getIntent();
String[] message = notificationIntent.getStringArrayExtra("notify");
Toast toast6=Toast.makeText(this,""+message,Toast.LENGTH_LONG);
toast6.show();