here is what i do and its not working ... i get time from shared preference from timepicker this time is picked by user at runtime name as first time ... and in the fragment i need to compare system current time with first time to send notification . but if condition is not working during comparison. and when i remove if condition and then notification works good problem is in compare time . it do not show me any error.
public Long firstTimeinLong;
@SuppressLint("NewApi")
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
getActivity().setTitle("Blood Pressure");
View view = inflater.inflate(R.layout.fragment_blood_pressure, container, false);
Date myDate = new Date(); // Default Value.
Long dateTimeinLong = myDate.getTime();
SharedPreferences prefs = getActivity().getSharedPreferences("MY_PREFS_BPTIME_CHECKS", MODE_PRIVATE);
firstTimeinLong = prefs.getLong( "millis1",0 ); // firstTime1
System.out.println("System Time : " + dateTimeinLong);
System.out.println("First Time : " + firstTimeinLong);
if (dateTimeinLong == firstTimeinLong.longValue() )// i dont know why this is not working but i do not get any error
{
LGSnackbarManager.show(INFO, "first time is here in the loop");
Intent notifyIntent = new Intent(getActivity().getApplicationContext(), NotificationBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getActivity().getApplicationContext(), 12345678, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) getActivity().getApplicationContext().getSystemService(getActivity().getApplicationContext().ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),1000, pendingIntent);
}
return view;
}