I need to set multiple notifications at the same time based on a list of mutiple choice questions. I will figure the radio buttons and if statements out later, for now I'm just setting the dates randomly for testing purposes.
If the user selects jan 1st and clicks a button. It will set a notification in the future with a reminder to do an activity. It also saves this information so the user can edit the details if he desires or change a few options.
This part I already have coded and it works just fine. however, It only sets a single notification currently. It is a pretty involved code consisting database, receivers, fragments, etc. that all talk to each other.
As I said, this part I have working just fine but I am not including all the code because it is seriously involved and no one would try to break it down if i drown you in a sea of code. I can certainly post specific code if someone request it.
My issue is that I need it to set a good amount of notifications at various future dates upon the button click, not just one. I need to change the notification message to a preset variable string for each additional notification event but some things like title will remain the same.
my current working code executes like this....
User Selects Jan 1 > User Clicks Button > Notification set for Feb 14 with a unique title and message set by the user and saved for future editing...
At the same time the notifications are set they are saved so the user can change the date and a few options if needed. I want only one title and a single date saved. I have the save feature already working but I need to know how to link the additional reminders to the existing saved item. Im trying to make all the data linked so that if the user deletes the saved item, all the set notifications for that file are deleted and not just the one that falls on the user selected date.
===== This is what I am trying to pull off
User Picks Some Options and Clicks A Button [I have this working already]
Upon Click of said button, the following notifications are all set in the future :
[currently it sets this notification only]
Jan 1 notification :
(title)Day Master App
(message)Happy New Year
[Im trying to figure out how to add the following notifications upon the above button click and also save this information to the existing db under the same item]
Feb 14 notification : (title)Day Master App - (message)Its V Day
March 1 notification : (title)Day Master App - (message)Spring Is Near
March 14 notification : (title)Day Master App - (message)Its probably raining
(((and we'll just pretend i finished the list...)))
I cant make the future notifications a static number because when the future notifications are set is determined by a bunch of radio button choices before the user clicks the execute button. This is going to be a pretty complex and hacky if/else novel the way I think I have to do it. Am I correct?
I have a display/edit listview that shows your saved notifications and the unique name and date the user set. This works fine currently but only sets a single notification based on user input.
I need to add some more notifications but i dont need to save them under a different item or name. I want them all under the same save item so all the notifications that were set when the button was clicked can be added and deleted as a group. There will be no option to delete certain notifications that were set. It will be all or none.
I would imagine I could just add some more variables into the existing "save notification" code? As in piggyback some more items (like all the dates and messages) for the additional notifications? do i need to write a new function for each future notification I set in order to be able to delete it?
do I need to create a new db for each additional notification that is set? A separate Adapter? Im so confused...
===
Im not looking for a code example exactly, I want to know how this would be implemented into an existing code. I realize there is probably 100 ways to code what I have described. I just need the process explained.
Please explain this to me slowly. I know im way overthinking this.
I tried to explain this as best I could, if you need clarification on something please ask. Thank You.
I have solved my problem although I could not accomplish exactly what I was trying to originally.
I managed to set the multiple notifications on a single click with different dates by simply copying the same code I used to display the single notification and simply giving each additional notification a unique ID and creating a new variables to give them individual text, future dates, separate times, etc. These variables can be easily set programmaticly or by the user when you set them up.
// On clicking the set notifications button
public void SetNotificationsButton(View v){
ReminderDatabase rb = new ReminderDatabase(this);
// Creating Original Reminder
int ID = rb.addReminder(new Reminder(mTitle,
mDate, mTime, mRepeat, mRepeatNo, mRepeatType, mActive));
// Create Feeding Notification
int FeedingID = rb.addReminder(new Reminder("Have you fed the cat today?",
mFeedingDate, mFeedingTime, mRepeat, mRepeatNo, mRepeatType, mActive));
}
//
// and just continued copy and pasting the rest of the notification events
// changing the ID for each individual notification. Without a unique ID
// the current notification will override the previous notification and
// appear to only set the last reminder.
I was not able to remove all notifications by selecting a single list item, I probably could have figured this out by grouping the notifications into a separate variable but once I realized that you can only have a maximum of 50 notifications set at any given time it seemed like overkill.
Since I have a repeat option for certain notifications I can keep my notifications set; numbers low and stay away from the 50 at a time limit while still firing a reminder to the user every day.
I found a great example for setting single notifications I used as reference.
https://github.com/blanyal/Remindly
Thank those of you who took the time to read my question.
Related
I can successfully retrieve documents from firestore, the trouble is, i do not know how to put them back where they came from!!
My app is a court booking system, it uses 7 fragments that represent the days of the week. Each fragment contains buttons that represent booking slots throughout the day. When a button is pressed, the court booking activity fires showing textviews and spinners.
The information I save to firestore includes a unique number representing a datestamp and a booking id that represents the id of the button that was pressed.... from here, I am lost, i need to write the retrieved database info back to their relevant places but i dont have anything unique in the way of widgets. The buttons are unique but all they do is fire a non unique court booking activity... any help appreciated... sorry for length, quite possibly more to add when answering questions.
To write to a document in Firestore you need to know the complete path to that document. You'll need to track the necessary IDs in your code, in a way that you can synchronize it with your UI elements.
A simple first pass could be to add a non-editable view (e.g. a label) to your UI for each document, and set the document ID (or entire path) in there. Then when the user clicks a button, you find the corresponding view with the ID, and from that can recreate the DocumentReference that you need to update.
in android stuido I would like to code an activity, where the user can input numbers. For, example he types the number to the textfield, click 'OK' button, then the textfield gets clear, he types the second number, than the third, and after they give the third number the program goes to another activity and sayst thanks for the free number. I would like to save the three numbers for further use and have them in an ascending order. How should I do it?
I agree with Andrii, this is a very vague and general question. To get you pointed in the right direction though, you would want a layout with an number based-editText widget (for the user input). I would then add the button, and then implement OnClickListener for the button so that everytime the button is pressed, it calls a method you will define that will store the value in an array or list (which can be sorted), along with some kind of tracker to keep track of how many numbers have been entered - then clearing the editText field so that another number can be input; on the third number, the method calls the activity via intent or some other way saying "thanks for the free number".
This is all general and it is going to take quite a bit of work and API Guide/DeveloperDocs searching on the Android web site.
I'm making a very simple launcher for Android. I'm having trouble getting some speed dial buttons to work.
The idea is that when the user presses the speed dial buttons for the first time, they'll be prompted to enter a phone number with a popup window (dialog? I think?). That number will then be assigned to that button, which will then call the assigned number when the button is next pressed. It's not great if they want to reassign a number, but this is just something rough that i'd like to get out of the way. I'm thinking of creating an int to reflect the state of the button (0 = no number assigned, 1 = number is assigned), and using if statements to either bring up the window or call the number.
I don't know how to bring up such a window (although I do know I can bring up a dial pad using (android:inputType="phone")), as well as how to pass the number that the user inputted to an int/long. I'm thinking I can assign the value to an int, although that might not be the most optimal data type. I have a rough idea on how to dial a number once it's given.
What should I do? I'm quite new to programming, so i'm having trouble with this.
may be this could help.
have a long click listener to the buttons.
on long click event, show a dialog widow which accepts the number.
store it in a persistent memory, either db, files or pref utils by android.
in on click button, have a logic to retrieve the stored content and update the views accordingly.
I'm making a app that can reserve message from php server and append new message in listView,
then mark a point on that item to show unread,of course it will disappear when click the item,
these is my question:
how can i save the read/unread mark on each item in order to when i login the app next time i
still can see the mark.
I have tried using share preference but it seems not a good solution.there is so may key to save and it's inconvenient when modify the value.
is it need SQLite ? or have easier solution? need some to help.
I'm working on application and I need some suggestions which is the best way to code it for Android. Basically it's something like event guide for a few cities. Imagine this :
I have an activity with 7 different buttons (7 different cities) and clicking on one of these buttons I'm opening a new activity where I have all months (January-December) as buttons again. If there is some event in February for example in the chosen city the button will be active and I will go to another activity where I have a list with the events. So my idea is to do it in this way :
Create one Activity with all Cities
Create one Calendar activity with all months.
When user select for example Paris, I'll send an extra via intent with an ID of the chosen city :
intent.putExtra("chosenCity", 2); //something like this
In the Calendar activity I will make active/inactive months buttons depending on that extra sent from Cities activity.
And when user chose a month I will send that chosenCity extra again to the ListViewEvents activity and populate the list view from Database (for example) depending on that extra.
So my question is : is it a good way to build an application like that? Or if it's not, which is the best way to achieve this?
Thanks in advance!
Sounds like you already know pretty much what you need to do. The only thing left is to implement it. The only thing I'll add is that your should probably store all your database and use a CursorAdapter to display them in the ListView. You can store all the events in the database and just create your select statement in such a way that it only selects the events you want to display at any given time. When using this CursorAdapter, I highly recommend you use the CursorLoader.