App Inventor 2: Invalid Destination Address - android

I'm getting the error when InviteButton.Click is pressed, when trying to send the actual message. Everything else loads up as it should, I am able to select a contact etc.
I've the following block of code:
I'm using contact picker to pick the number:
Then I'm trying to call the value stored in the tinyDB and send the message like this:
And this is the error i get:
Basically I'm trying to pick a number from the contact picker, add to the tinyDB and when I press a button it sends the text message....can't figure it out.
Any ideas??

You should add some data validation before sending the message, something like this
By the way, the if true statement does not make sense, you can remove it...

Related

android comparing text to save image and send via bluetooth

i make a project for hearing impaired people ,where two devices are connected via bluetooth , its already working sending and receiving messages but what i want is when i type a text "hi" in a editext and when i click the send button the display would be the picture in a right(girl picture) but if that picture is not available display the second picture in left side(hand sign) , is this possible? can i compare the txt i type to the drawable folder image so that , that particular image will display?... ..
plz share ur idea....
Then you will need the following:
get the text (Hi) before displaying it, by getText
check the availability of the image either you want it to be available in phone 1 or phone 2 by this method
Sure it is possible to send an image via Bluetooth, also you can code it as this example
Also my opinion is to upload the image to the firebase or let it with your application if you need it for much use
Edit : compairing file name with string that you want is like is
boolean fileExists = new File("path/to/" + name + ".png").isFile();
where name if the chat message you want to compare and surely, that code occurs before the texts/images are displayed to the users

How do I set multiple notifications using one date selection?

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.

Android: How to getNetworkOperatorName and location from incomming/outgoing number?

I am Developing a simple application on CallLog.Calls. I am also following Calllog.Calls .I am Getting all the call details like.. callername , caller number , calltime , duration..etc. As per the requirement I need to check the unknown number location/caller networkprovidername like TruecallerApp and like this image
In short I want to know how can i get or trace the Caller Locationprovidername from the incomming/outgoing number in android programatically ???Is there any database i need to create with all the related data or any other way to solve this?? By using telephonymanager.getNetworkOperatorName() i can get the own device operator name similliraly i want to get for other number. Any Idea Please Rply soon .
Thank you :)

How to use a file like a LIFO?

My application sends a packet every 30 minutes. When the packet can't be sent, I want to store it (a simple string) inside a file called error.log. When the user presses a button called "restoreErrors", I want to extract a packet from error.log and try to resend it, according to the LIFO policy.
For example the file error.log is:
String1
String2
String3
And when the user presses the "restoreErrors" button, I need to load the saved packets in order:
while (!file.empty) {
String str = loadUnsendedStringFromFile();
}
My problem is using the file like a LIFO, because I can read the String correctly, but I need to remove the currently extracted string (like POP in a stack model).
Thanks.
EDIT: Ok, I will use a simple list for achieve this, no need to store inside a file for every packet error... thanks
With an ArrayList, you can call the add method to add unsent messages to your list. Then you can send them in the order you want (going up or down, with a simple for loop). Then, call the remove method to erase the sent string, it will leave you with the unsent Strings

Setting the cursor to end of the body in Gmail Android Programatically

I needed to send email programatically with some info in the body of email.
User will add more info after the info I added programtically in body of email. I can now send the email with the text in the body.
Now the problem is that when email intent is opened the text I added is shows in body of email but the cursor is at start of that field. All I want to do is to move it to the end of the text I added. So that users can easily add their info into it. Is it possible? If so how?
I doubt this is possible since the Intent leads to the Mail application and you surely cannot change its code. The better solution from the user experience point of view will be to create a form so your users can enter all required data inside your application, without the need to alter e-mail message contents. Hope this helps.

Categories

Resources