Is there any way of controlling an incoming phonecall on UWP? I'm looking for something like:
1. Get IncomingPhonecallEventHandler to attach
2. When triggered, be capable of:
phonecall.Accept();
phonecall.Decline();
phonecall.DeclineWithSMS();
All of this is a part of my android smartwatch project, so I need to be able to call and recieve calls as well.
EDIT 1
I know the PhoneCallManager class, but registering for CallStateChanged event returns object, which I don't know how to use.
I believe you are looking for the PhoneCallManager class and the PhoneCallManager.CallStateChanged event.
You can also checkout this example (in C#) to see how to interact with the apis
If you want to be able to block and filter calls, you can checkout this example, it has that capability.
If you want to send SMS, this example has the code needed
However, I don't believe there is an API to answer phone calls at this time
Related
I would like to write a program that can intercept the windows message that is sent when I press the button on my apple headphones and remap that to send a message to my desktop pandora app to play/pause. Is there already a utility that accomplishes this? Does the .NET framework give me access to these messages? Would I be able to access the message before it is sent to it's default program?
Is there already a utility that accomplishes this?
No clue. Probably not. SO isn't for recommendation questions anyways.
Does the .NET framework give me access to these messages?
No. Not easily anyways.
Would I be able to access the message before it is sent to it's
default program?
I don't know about timing, but you should be able to access it. You'll need to set up a hook (MSDN). Unfortunately, this is in the Windows API and so you'll need to use PInvoke to actually call the native (C++) methods needed.
Corodva, Javascript and HTML5 developers.
I need to intercep all get requests made by the WebBrowser component in Windows Phone 8.0 at any point and be able to view the resource that it's requesting. To give an example of "all", this is what I mean.
I have a simple application that contains a cordova(WebBrowser control with Decorators that allows XHRrequests to be retrieved from local storage) view, and navigates to an index.html file.
The index.html contains only the following in the body
<img src="logo.png" />
This file is loaded and displayed by the web browser but there is not interceptable request made through the web browser to the Windows Phone that I can see. The file just appears in the browser magically. I know that cordova overwrites all XHRrequests to swap out for local files. No method in the XHRHelper.cs is being hit with a request for logo.png. Here is everything I have tried just so we can all be on the same page.
Subscribed to the Navigating, Navigated and NavigationFailed (Just because there's no other option) events to see if it fires at any point to load logo.png. This turned out nothing, it only fired for actual navigation calls made within the application. I also subscribed to all, I literally mean all events available from the WebBrowser control. Even ones that are inherited from UIElement.
Tried to wrap the WebBrowser in a COM Wrapper that "monitors" all outgoing traffic using http://www.codeproject.com/Articles/157329/Http-Monitor-for-Webbrowser-Control which does not work for Windows Phone 8.0 Web browser control. Was still a good exercise. It also does not get requests made for local files.
The next option I checked out is a way of intercepting all requests from JavaScript for anything, but found many posts that only explain how to intercept all AJAX requests, which is not what I want to do.
I then implemented the ways of intercepting all AJAX requests to see if it will give some insight on what I could possibly do. Nothing panned out from this exercise. I then also did this [How do you 'intercept' all HTTP requests in an EmberJs app?. Ant that also did not help, I then looked at intercept.js and tried to use that, but again the logo.png slipped the grasp of intercept.js aswell
Me being a Windows Phone .NET developer and not at all experienced in JavaScript except for 6 months of wrapping HTML5 apps into cordova I returned back to the windows phone code trying to catch the navigation as it leaves the WebBrowser control. I tried to override all the methods that were specific to a WebBrowser and tried to cancel any and all requests, just to see if logo.png would still appear in the browser and it did :(
I wouldn't ask this question if I didn't do any research on this subject. Some of the JavaScript devs said that they don't think it's possible from inside the application, many of the C++ developers said I should look at the native code implementation for the WebBrowser control, find out what interfaces it extends and get hold of it for extension somehow. I will be attempting to do this tomorrow all day, but would like to not overkil the situation if there's (hopefully) an easy way of doing this.
My next step is to use a tool like fiddler or charles to monitor all packets through a proxy. If I can see requests made for the local files through any of these tools then there must be a way to intercept those requests in code. If this is successfull I will attempt to set up a local proxy at runtime and redirect through my filehandler.
I spoke to some iOS developers and they used NSURLProtocol, which you just have to set up then you can monitor all you traffic (Lucky). Is there anything like this for Windows Phone 8.0? Does anyone have suggestions on how I could implement this for Windows Phone 8.0? Is there any way I can intercept all requests from a html5 app. Any way would be fine, I'm fairly confident that I'll be able to implement any suggestion and give feedback if it does not work. The biggest question would be if it's even possible.
Any feedback would be appreciated, and any suggestions will be followed through. And I will provide feedback on that suggestion.
Thank you in advance, I know there are some serious Code Ninjas on here that will give me a million options :)
I have found a very simple solution to this problem. Since Mobile IE10 does not provide functionality to intercept requests made by a webpage I moved off that path and chose to not intercept the requests but rather redirect it.
I did this by setting up a socket server on the phone and requesting the assets in the HTML5 application from the localhost. Here's an example:
A file that I used in the index.html like below
<img src="logo.png" />
I changed to
<img src="http://localhost:99/logo.png" />
This way you get a Process request event fired in the socket server where you can handle your asset request appropriately. You can take the logo.png and give back a image with a different name by using a simple mapping in the socket server, which is what I needed to do.
I hope this helps someone dealing with the same problem :)
I would like to build a bot - web crawler - to collect phone numbers.
I have a problem though: to see the phone number, a user must click something like "Show".
How can I solve this problem?
Check what the act of clicking on the button does. Does it call a Javascript function? Does that make an HTTP call to a backend? If so your bot should do that call instead of screen-scraping the first page. If not, does it just play with the DOM of the page to show an item on screen?
All the data you're looking for comes from some sort of back-end, so if you look in the developer tools of your browser when going through the page you can usually figure out what calls to script in order to get the data.
It is possible to make this harder (and that is what some sites to to protect themselves from scraping). Typically if you're in this situation, what you're doing is not entirely legal or nice. But technically it's very interesting, so here goes.
The best way to go forward is to run the site in a real browser (like PhantomJS, or Chrome) and use a framework like Webdriver to simulate browser interactions. This way you can pull most of the data out usually.
If you find that your ip gets blocked, you may use Tor and use multiple instances dynamically to hit the site... but make sure you ask the site owner nicely if you're allowed to do that of course.
I want to make an application to intercept all UI events in all the forms of my application and to write them to a log. This data can than be used to see which controls are the most used, in what order, etc. The problem is that I want this to happen automatically, without modifying the existing classes.
I made a prototype that attaches a method to a click event for all controls in a form, but how can this be done for all forms? Reflection needs a target object when manipulating events, but only the startup form can be easily accessed.
Is there a way to hook the constructor of an object? Then I could "inject" my method in all the events of the new form. Or maybe there is another way to do this.
Thanks in advance!
You can install a message filter.
A message filter is an object that implements IMessageFilter. WinForms calls your PreFilterMessage method for every message that passes through your thread's message loop. This is enough to monitor user input across the application (and gives you the option of manipulating it).
In Windows API this is done using local hooks (you can set local mouse hook using SetWindowsHookEx function). This is the proper way to do your task. In C# you need to use P/Invoke in order to get access to SetWindowsHookEx.
One more task would be to match the HWND (windows handle) to corresponding WinForms control.
Read this article for how to do this (via WM_GETCONTROLNAME message).
Also see this question which is a duplicate of yours.
You will have to work with the Win32's API Messages, I guess.
Here's a little example under the form of tutorial.
You should be able to achieve what you want with message filters - no direct P/Invoke to Win32-APIs required!
See the help on the IMessageFilter interface for more info.
I'm looking for the best way to constantly check if data has been sent to our ASP.NET MVC application from a server. I would like to asynchronously check for data and update the view when data has been read.
I'm currently using a TcpClient to make a connection, and making the connection in the inherited custom base controller. Currently though I have to refresh the page for the updating of the view to take place.
Would there be a proper AJAX solution? or do I need to move the connection to the ActionMethod?
For complete solution use this free library : PokeIn
I would probably use jQuery to query some action at a specified interval and update the page accordingly.
I don't know what kind of data you're talking about, but let's look at a simple example. From you're question, it sounds to me like you're trying to do the following:
Suppose you are building Twitter and want to show the newest Tweets on the homepage. Well, you could have a script that just does a jQuery.GetJSON call to some URL (let's call it twitter.com/latest5tweets) that gets the latest 5 tweets. Then you would have a callback function that would take those tweets and paint them on the screen -- perhaps using some sort of nifty slide effect to remove the older ones from the screen and add the new ones.
Does that help?