I tried using the following code but its not working as the app closes immediately without even showing compose message task:
private void Button_Click_1(object sender, RoutedEventArgs e)
{
SmsComposeTask smsComposeTask = new SmsComposeTask();
smsComposeTask.To = number;
smsComposeTask.Body = "I'll call you back.";
smsComposeTask.Show();
Application.Current.Terminate();
}
Is there a way to close app after this button is clicked and sms task has been completed?
i added a 500ms delay between show task and terminate.
the app went tombstone in this time and couldn't execute terminate statement.
smsComposeTask.Show();
System.Threading.Thread.Sleep(500);
Application.Current.Terminate();
I assume that you're trying to make a shortcut app and hence you would like the app to close after launching the specified Task.
There's no need to use Thread.Sleep as there is a better approach for achieving the same.
You can call your SmsComposeTask in the App.xaml.cs file in the Application_Launching event
And then call the Application.Current.Terminate(); when the app is sent to Background in the Deactivated Event (Application_Deactivated)
Looks like your app closed before the separate messaging app starts.
Why do you need to close the app? It's in the tombstoning state if you launch a messaging task (from MSDN):
Windows Phone applications are not able to directly access common information stores such as the contacts list or to directly invoke other applications such as phoning or messaging. To support scenarios requiring common tasks such as phoning or messaging, the Windows Phone provides a set of launcher and chooser APIs that enables applications to access these useful phone features indirectly. The launcher and chooser APIs invoke distinct built-in applications that replace the currently running application.)
Related
When the user downloads the app and opens it for the first time, a splash screen should show telling him to log in or other stuff. Then, every time the user re-open the app it should check for if the user is authenticated or not.
Can I do this with hydrated_bloc?
If you are using Firebase backend then on each launch of the app you will call firebaseInstance.currentUser() to check if authorized or not and this check will be through an event from the bloc when the app launches
If you are not using this backend then also on each launch of the app you will call some method to check if auth token (if exists) is still valid also through an event from the bloc
Now the HydratedBloc can save the previous state of the app but suppose you save the previous state and the user doesn't open the app until after token expires and you are using HydratedBloc so you will only rely on it to check the previously saved state (auth status) and not use the methods above so in this case you will login an UNAUTHENTICATED user into the app.
And if you say I will also do the above methods then what is the point of using this bloc in this case?
So looks like it is an overkill to use this bloc for this feature
what does these methods Means in android studio in google map
1).OnMapReadyCallback
2). LocationListener
3). GoogleApiClient.ConnectionCallbacks
4). GoogleApiClient.OnConnectionFailedListener
from Android Developer docs:
LocationListener
public interface LocationListener
android.location.LocationListener
Used for receiving notifications from the LocationManager when the location has changed
it is just like using OnClickListener to detect a user's click, but it listens for changes in location. you can use it to perform a set of instruction when the user have localisation enabled and moves to another location.
GoogleApiClient is The main entry point for Google Play services integration, is what you use to connect the client (user, to the google play services
GoogleApiClient.OnConnectionFailedListener public static interface
GoogleApiClient.OnConnectionFailedListener Provides callbacks for
scenarios that result in a failed attempt to connect the client to the
service.
it is used to define what should happen (just a set of instructions), in case your attempt to connect to the google play services has failed
GoogleApiClient.ConnectionCallbacks public static interface GoogleApiClient.ConnectionCallbacks Provides callbacks that are
called when the client is connected or disconnected from the service
this is very similar to the previous one, but instead of defining what should be done when a the client fails to connect, it defines what should be done, when a connection to the google play services is successfully established, or if a disconnection with the services has been preformed.
as for the rest :
i got this information from the documentation,
i invite you to read it before posting, it contains all the information that you may need, and try to implement the methods your self to understand how they work
I have a button in my Windows Phone 8.1 RT app. When the user clicks the button, 2 SMS are supposed to be sent to two different users.
I can launch one SMS Task using the following code
var message = new ChatMessage();
message.Recipients.Add("1231233");
message.Body = "This is a text message from an app!";
await ChatMessageManager.ShowComposeSmsMessageAsync(message);
But when I do this multiple times, the app crashes. The Task complete event fires on task launch, is there a way to know if the user has returned to the app after sending SMS so the next one can be fired?
If the ShowComposeSmsMessageAsync is anything like the MessageDialog.ShowAsync method, which seems true as both return IAsyncInfo objects (..Action/..Operation is different, but the async part is important for us), this problem could be solved like the problem of showing multiple message dialogs. A quick search yielded this question, with multiple correct solutions: How to allow for multiple popups at once in WinRT?
If the above doesn't work, you could - for example - subscribe to the VisibilityChanged event of the app Window (https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.window.aspx), as it should provide you with an event about the user returning from the sms task.
So basically 1. subscibe to event, 2. send 1st sms, 3. wait for event, 4. send 2nd sms.
I am new to WP8 Aync tasks and have a query-
In WP8, on backbutton press, since it basically pops the last screen from the stack, then why are the Async tasks not cancelled when back key is pressed?
Also, if I am using the HttpWebRequest response, is using Abort() the only way of cancelling the async tasks?
The reason is because Back is a UI concept but things like networking are typically decoupled from the UI. As an example, imagine the user hit "Save" in an app and that started a web request to send their data to the cloud. Then they hit the Back button to go back to the previous page; it would be unexpected for the web request to be aborted and the data to potentially not be saved.
If you have a need to stop tasks when your UI changes (eg, because of resource consumption concerns) then you can try to do that, but I have a vague recollection that Abort is a no-op for Windows Phone 8 (but I could be wrong).
I'm writing a chromecast receiver application that will (hopefully) allow me to remotely put alert messages up on my TV to serve as reminders.
My plan was to have a dedicated wireless device on my home network that would constantly poll for new messages from a centralized server. When a new message was found, it would connect to a chromecast route, turning on the TV and displaying the new message.
But as far as I can tell, the only way to activate a chromecast route is by manually clicking the chromecast icon on my Chrome browser or wireless device.
Is there a way, programmatically, to activate the chromecast? Can it be done in the sender?
You can programmatically scan for cast devices and connect to them if needed. Steps are:
Get an instance of the MediaRouter singleton from the system: mMediaRouter
Build a selector:
mMediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(
CastMediaControlIntent
.categoryForCast(YOUR_APP_ID)).build();
Add a callback to initiate scan:
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
MediaRouter.CALLBACK_FLAG_PERFORM_ACTIVE_SCAN);
The onRouteAdded() and onRouteRemoved() of your callback (i.e. mMediaRouterCallback) will be called as routes are discovered or removed. You can maintain a list of routes in your app and keep them up to date by using these two callbacks.
You can select a route by calling mMediaRouter.selectRoute(aRouteInfo). Then the onRouteSelected() of your callback will be called and you can extract the cast device as usual and do as you please.
These said, remember that if you want to show a notification to users on TV your app should be running on the chromecast at the time you want to send the notification.