How to dynamically modify callers name - android

Is there a way how to dynamically modify the name that appears on the screen when somebody is calling?
For instance, I have a number "123456789" in my contact list under the name "Bill Gates". Now when the number "123456789" calls me, I want the corresponding name that appears on the screen to be changed to for instance "Test".
I have a broadcast receiver that is listening to incoming calls. Once I get the call with particular number (123456789), I change the contact name to the corresponding value (Test).
The contact name gets changed to "Test", however the name visible on the screen during the phone call does not change.
Isn't there something like an observer pattern where all the receivers get notified once the contact has been updated?
I tried contentResolver.notifyChange(URI_CONTACTS, null, true), however does not work
Thank you in advance for any suggestions

Is there a way how to dynamically modify the name that appears on the screen when somebody is calling?
No, at least no universal method which fits your scenario. The phone app would have to check for changes of the caller name by itself. As your test shows this does not apply to the phone app you are using.
Isn't there something like an observer pattern where all the receivers get notified once the contact has been updated?
Still, the phone app would have to register itself as an observer.

Related

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 call phone number with respective name in android

Trying to call number with name.It is possible to make name with number calling.
I successfully calling following code:
Intent callIntentp2 = new Intent(Intent.ACTION_CALL);
callIntentp2.setData(Uri.parse("tel: 55555555");
startActivity(callIntentp2);
It's Output looks like
55555555 Dialing
But I want to call with name just like you saved on contact list on your sim.but i have data in manually not from sim.
John 55555555 Dialing
Is that possible.
ACTION_CALL is a native Android intent. When you call it, Android performs background processes that bring up the default call view. There are ways you could chop together some broadcast receiver to overlay an activity on top of the native call screen, but you are asking for trouble on that end. Without a rooted device, this is a difficult process. This question is actually very similar to:
Replace native outgoing call Screen by custom screen android
I haven't read through the link or anything, but I am pretty sure they are going to say the same thing. Without doing some weird, iffy work-around you aren't likely to achieve this.
You could (theoretically) take the time prior to calling to add the number with the attached name to your contacts list. When the call is made, it will show the name and the number (since the name is listed as a contact and that is Android's default action). Once the call is done you could delete the contact so that it doesn't get stuck in a persons contact list that doesn't want it.
A bit of code for example:
ContentValues contactValues = new ContentValues();
contactValues.put(Data.RAW_CONTACT_ID, 001);
contactValues.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
contactValues.put(Phone.NUMBER, "555-555-5555");
contactValues.put(Phone.TYPE, Phone.TYPE_CUSTOM);
contactValues.put(Phone.LABEL, "John");
Uri dataUri = getContentResolver().insert(
android.provider.ContactsContract.Data.CONTENT_URI, contactValues);
Don't forget to add write contact permission to your applications manifest. Again, this is just an option (the only one I can really think of off the top of my head)

get unique call details from CallLog

I am trying to access call logs in android application , here i am getting all call details but i want unique call details only , i don't want repeated values.
is there any way to get unique call log details in android ?
Get all call details and add them in Set. Set does not allow dupes.
Idea and guess:
If you are extracting each detail differently you might find easier to use Map and then add the keySet() to the Set data and then again you populate the map.
Remember in CallLog you might find same key (let's say Contact name) but different data for that call (Time, duration etc etc).

Android create contact problem

Hi
I wan to create a contact, so here is my code:
Intent addPersonIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
addPersonIntent.putExtra(Insert.NAME, "asd");
addPersonIntent.setType(Contacts.People.NAME);
addPersonIntent.putExtra(Insert.PHONE_TYPE, Contacts.Phones.TYPE_WORK);
addPersonIntent.putExtra(Insert.PHONE, Uri.decode("123"));
addPersonIntent.putExtra(Insert.PHONE_TYPE, Contacts.Phones.TYPE_MOBILE);
addPersonIntent.putExtra(Insert.PHONE, Uri.decode("123"));
addPersonIntent.setType(Contacts.Phones.CONTENT_ITEM_TYPE);
...
startActivity(addPersonIntent);
Why the only thing that is created is the mobile number, I never got the "work" number?
You're thinking of "putExtra" as adding to the end of an array - Your problem will be clearer if you think of it as setting name/value pairs in a hashtable. Basically, you're setting PHONE_TYPE to "work", PHONE to 123, PHONE_TYPE to "mobile" (overwriting when it was set to work), and PHONE to "123" again.
What you want to do is set either the "mobile" or "work" phone data using SECONDARY_PHONE and SECONDARY_PHONE_TYPE - Details here.
Also, keep in mind that all this follows the old version of the Contacts API, which is deprecated as of Android 2.0+. There's a handy resource on migrating your code to use the new contacts API here.
here is the next problem, when I add:
addPersonIntent.putExtra(Insert.NOTES, "asdkjhaskh");
the note data never appears in the activity, why?
The whole idea is to start the EditContactActivity.java with loaded data and for now I loaded phones, names and companies. For some reason I cant load notes, and another problem is how to set in the intent information for the IM? For example I tryed with:
addPersonIntent.putExtra(Insert.IM_HANDLE, "mySkype");
addPersonIntent.putExtra(Insert.IM_PROTOCOL, Uri.decode("skype"));
but it is not working.

Categories

Resources