0

I'm trying to pass an EditText value to an Alarm receiver Activity, what the EditText does is put a number pertaining to the amount of that particular alarm. When the alarm is answered the EditText should int--, I have everything else working but I can not figure out how to package up the process of:

amountt++;
amountText = Integer.toString(amountt);
amountedit.setHint(amountText);
amnt.setText(amountText);



editor.putString("numbers", amountText);
editor.commit();

From the set alarm activity to the Receiver activity:

        @Override
        public void onClick(View v) {

             mPlayer.stop();
             amountedit.setHint(amountText);
             amnt.setText("value"+ amountt--);

                finish();
                stoplaydialog.dismiss();
return;

I've tried a few things so far such as:

  carry = new Intent();
  carry.putExtra("numbers", amountt);
  startActivity(carry);

To :

  String value = getIntent().getExtras().getString("amount");

But I can't figure out how to "unpack" it and put it into the context of

amnt.setText("value"+ amountt--);

I'm very new to this, a little holliday hobby so I appologise if this is a stupid question. Thanks.

EDIT: Launching from this now..

Intent intent=new Intent(CaAdd.this,AlarmReceiver.class);
    intent.putExtra("numbers", amountt);

    PendingIntent pi=PendingIntent.getActivity(CaAdd.this, 2,    `intent,PendingIntent.FLAG_CANCEL_CURRENT);`
   AlarmManager alm=(AlarmManager) getSystemService(Context.ALARM_SERVICE);

But I'm getting a int:null error on the AlarmReceiver activity.

ToeKnee
  • 47
  • 1
  • 10

1 Answers1

1

You have call wrong intent. It should be:

String value = getIntent().getExtras().getString("numbers");

instead of:

String value = getIntent().getExtras().getString("amount");
Avijit
  • 3,834
  • 4
  • 33
  • 45