0
My problem is this... I have a routine of notifications that the user click on the notification screen, open a new Activity. In this new Activity I show some information that I search in the database depending on the code I pass by parameters, however, I am not able to recover this code in the new Activity.
I will put the classes to explain better:
This class below I call as soon as I enter the notification in the database:
public class AlarmUtilSessao {
// Agenda o alarme com repeat
public static void scheduleRepeat(Context context, Intent intent, long triggerAtMillis, long intervalMillis, int id) {
intent.putExtra("ID_SESSAO",id);
PendingIntent p = PendingIntent.getBroadcast(context, id, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarme = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
alarme.setInexactRepeating(AlarmManager.RTC_WAKEUP, triggerAtMillis, intervalMillis, p);
}
}
In my Manifest I call by receiver the class that makes the notification:
<receiver android:name=".Lembretes.LembreteSessao">
<intent-filter>
<action android:name=".Alarm.Lembretes.LEMBRE_SESSAO" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</receiver>
My class that is triggered by the receiver is the one below. I correctly receive the ID and work with it in the database:
public class LembreteSessao extends BroadcastReceiver {
private static final String TAG = "Sessao";
public static final String ACTION = ".Alarm.Lembretes.LEMBRE_SESSAO";
String currentTime, currentDate, newDate, newTime;
int Ano, Mes, Dia, Hora, Minu;
Date time, date;
SimpleDateFormat timeFormat, dateFormat;
JN_26_Alertas horarioModel;
//CLASSE CHAMADA PELO MANIFEST NO HORARIO DO ALARME
@Override
public void onReceive(Context context, Intent intent) {
ctx = context;
codigo = intent.getIntExtra("ID_SESSAO", 0);
Intent notifIntent = new Intent(context, lembrete_sessao.class);//alterar
notifIntent.putExtra("ID_SESSAO",codigo);
NotificationUtil.create(context, 3, notifIntent, R.mipmap.ic_launcher, "Sessao", "Verifique a Sessao");
//new Thread() {
// public void run() {
//...Acessos e manipulações do banco de dados
// }
//}.start();
notifIntent.putExtra("TIME", currentTime);
}
Hitherto the system received and correctly passed values by putExtra and getIntExtra, however, by clicking on the notification shown on the mobile screen, the value arrive on the next empty screen:
public class lembrete_sessao extends ActionBarActivity implements View.OnClickListener,
DialogInterface.OnClickListener{
private TextView horaReceita;
private int codigo, idRem = 0, qtd = 0;;
private ListView lista;
private JN_65_RemedioSessaoAdapter remedioSessaoAdapter;
private List<JN_25_RemedioSessao> listRemSessao = null;
private String msgSMS = null;
private RadioButton Whats, Messenger, SMS, Nenhum;
private String ConfiguracaoAlarme = null, Time = null;
private ArrayList<Integer> codArrayRemedio = new ArrayList<Integer>();
private AlertDialog alertConfirmacao;
private EditText foneSMS;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lembrete_sessao);
codigo = 0;
codigo = getIntent().getIntExtra("ID_SESSAO", 0);
Time = getIntent().getStringExtra("TIME");
//****
The variable TIME also arrives null, however, it is not of such importance... if I can get the value of the code I can recover the value TIME in the database... any suggestions? And thanks in advance.
use the Bundle both to pass and to receive?
– Joel Messias Do Nascimento
Yes, use the Bundle for two, the difference is that to pass is putExtra and to receive is getExtra.
– Leonardo Dias
Worse that didn’t happen either ...
– Joel Messias Do Nascimento
Make another simple app with just two screens, try to pass the parameters between them and tell us what happens.
– Reginaldo Rigo