Tap button programmatically in Windows Phone apps - windows-phone-8.1

I have 10 buttons with their name is from "btn1" -> "btn10". I created button6_Click event method like this. But now, I want to invoke the tap event on these button in the Initialize method of my page in my WP Apps. How can I do that, I found that Windows 8 app can do this but on the Windows Phone I can't find anything to perform this action.

Related

Check if any app can handle URI scheme

I'm creating a Windows Phone 8 app (Store apps) in which I will have some links for the user to open other apps.
My goal is to hide or show only the links for which I have apps that can handle them.
For instance, I have a link for
mymoneyapp://user=123
and another for
mymusic://user=123
So, if I have an app that can handle the mymoneyapp scheme I want the link to show if not then I hide it.
The only why I found to test this is using
LauncherOptions options = LauncherOptions();
options.FallbackUri = new Uri("http://myfallbackpage.com");
Launcher.LauncherUriAsync(new Uri("mymoneyapp://user=123"), options);
But in this case I get my fallback Uri launched if no app can handle that schema.
Is there any way just to test if an app can launch it without actually do it?
There is no API for this on Windows Phone 8. Windows 10 adds Launcher.QueryUriSupportAsync to allow checking if there is a handler before launching it.
https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.launcher.queryurisupportasync.aspx

Windows phone 8 push notifications

I have question about push notifications in Windows phone 8.
As i understand, there are three types of push notification:
Toast Notification.
Tile Notification.
Raw Notification.
So, in my opinion:
if the app is running, and opened in foreground:
Toast will be not shown, but i can handle it`s event and do something.
Tile will be updated automaticaly
Raw Notification must be handled by me. (Question one: can i do it without background task?)
if the app is running now, but suspended:
Toast will be shown as it came, without any event handling in my app, only "BindToToast()"
Tile Will be updated, without any event handling, only "BindToTile()"
Raw notification must be handled by background Task.
if the app is not open:
Toast will be shown automaticaly, if in previous launch "BindToToast()" was called.
Tile will update automaticaly, if in previous launch "BindToTile()" was called,
Question 2: what about raw notification? how to handle it here?
I think the situation is as follows:
Toast notification is shown only when the app is not running, but can be intercepted when it is
Tile notification always updates the tile regardless of application running
Raw notification can only be processed by the application when running.
Toast/raw notifications cannot normally be handled by a background task in Windows Phone 8.0. But there maybe a hack to get around this. See Windows Phone 8 notifications and background tasks and Windows Phone 8 Background Task with notifications
In Windows phone 8.1 it is quite possible to create a background task that is invoked when a notification is received, so the notification can be processed by the background task.

How to subscribe on Activated event in a Windows Phone 8.1

Do anyone know, how to subscribe on Activated event in a Windows Phone 8.1 Universal App?
In Windows Phone 8, I have used:
PhoneApplicationService.Current.Activated +=
WP8.1 Runtime has little different lifecycle - see MSDN. Depending on your needs you can use:
App.Current.Resuming event is called when you resume your app after it had been suspended by the OS - very often, typically few seconds after you navigate away, see also How to Resume an app,
Windows.Current.Activated is called when Window is activated/deactivated - you will have to check event's args. This event doesn't mean that your app had been suspended. You should also look out because this event will be fired for example when you show a dialog (when your window loses focus).
override methods from Application class - after using file pickers, sharing a target and more.
In windows phone 8.1 universal app use following code to subscribe for activated event.
Window.Current.Activated += Current_Activated;
Hope this helps!

Making call without confirm box in windows phone

I am developing windows phone 8 app, i need to make a call to specific phone number but without call confirm dialog. Is there any way to make a call to a number without call or dont call confirm dialog?
No, every call request generated using the API require user intervention due to security reasons.
phone call task is a Launcher and hence it has its own GUI.
The phone call task launches the Phone application and displays the
phone number and display name that you specify. The phone call is not
placed until the user presses the call button.
Source http://msdn.microsoft.com/library/windows/apps/hh394025(v=vs.105).aspx

Activated and deactivated events

When developing WP 8.1 Windows Runtime application, what’s the equivalent of the PhoneApplicationService.Activated and PhoneApplicationService.Deactivated events? It looks like PhoneApplicationService class is only available in Silverlight WP apps.
Application.Suspending event is not fired on Deactivated event (i.e. when I press Windows button).
You are right, under WinRT there is no Activated/Deactivated events. Your App can be Activated, but it's little different than in Silverlight. About the lifcycle you can read here at MSDN.
Your App will be Suspended just after you Navigate away from it. But - it's not working while you are debugging - more information here. When you run normally your App it will be suspended very fast after you hit Back/Start buttons.
About Navigation there is one thing you should be aware - when you Navigate away from the App, first OnNavigatedFrom is fired, then Suspended events (in the way you have subscribed them). But when you go back to your App - then Resuming events are fired, but OnNavigatedTo is not fired - reference:
Note On Windows Phone, OnNavigatedFrom() is called when the app is suspended. OnNavigatedTo() is not called when the app is resumed.
In some situations your App can be put into Not Running state. More again at Lifecycle at MSDN.