I would like to know how to open a link from a simple app that I have made to push a link from within the app from phone to open on the watch for example a link to google play store app to get downloaded on the smartwatch.
Thank you.
See the docs here https://developer.android.com/reference/androidx/wear/remote/interactions/RemoteActivityHelper
and an example here https://github.com/android/wear-os-samples/blob/d18c489ff415aa0fbb25c260e3aacdf50f7716e3/WearVerifyRemoteApp/Application/src/main/java/com/example/android/wearable/wear/wearverifyremoteapp/MainMobileActivity.kt
Log.d(TAG, "Number of nodes without app: " + nodesWithoutApp.size)
val intent = Intent(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.setData(Uri.parse(PLAY_STORE_APP_URI))
// In parallel, start remote activity requests for all wear devices that don't have the app installed yet.
nodesWithoutApp.forEach { node ->
lifecycleScope.launch {
try {
remoteActivityHelper
.startRemoteActivity(
targetIntent = intent,
targetNodeId = node.id
)
.await()
Related
I am sending an adaptive card to teams with the bot framework. That is working fine. The card should contain an action that opens a task module like explained here.
My code for the card looks like this:
AdaptiveCard card = new AdaptiveCard(new AdaptiveSchemaVersion(1, 3))
{
Body = new List<AdaptiveElement>() {
new AdaptiveTextBlock() {
Wrap = true,
Text = "test",
IsSubtle = false,
Size = AdaptiveTextSize.Large,
Weight = AdaptiveTextWeight.Bolder
}
},
Actions = new List<AdaptiveAction>() {
new AdaptiveSubmitAction()
{
Title = "In Teams",
DataJson = $"{{\"msteams\":{{\"type\":\"task/fetch\"}},\"Url\":\"{url}\",\"Title\": \"{title}\"}}"
}
}
};
The card is showing in teams, but the button is not working in the desktop client. It is just showing this message in red:
Something went wrong. Please try again.
In the web version the task module is just opening fine. Do I have to change something for the desktop version of teams? Tried to change my code a bit like in this example but that isn't working either.
Update:
So I tried the example and it did work one time. After that I had the same error message and no task module is showing. But when I pop out the App in a new window, everything is working fine. So it looks to me like a bug in teams.
I had the same problem with the message “Something went wrong. Try again.", when called Task Module from adaptive card. I installed the bot through a local upload of the manifest, but then I found out that it was also added to the list of applications for our organization, and apparently there was some kind of collision between them. After I uninstalled the application from my desktop Teams and installed it from the application pool - the error disappeared.
This might relate to how the platform is reading your json - the "" characters for example might not be handled properly on the desktop. To solve this, rather leave the json conversion up to the platform and, for your example in C#, create a strong type instead. The example you link to does exactly that - see this line:
new TaskModuleAction(cardType.ButtonTitle, new CardTaskFetchValue<string>() { Data = cardType.Id }
inside https://github.com/microsoft/BotBuilder-Samples/blob/448c5535cb6d6be8d7a61f78ef1902b55c1f0edb/samples/csharp_dotnetcore/54.teams-task-module/Bots/TeamsTaskModuleBot.cs, which is referencing this class: https://github.com/microsoft/BotBuilder-Samples/blob/901bc140f5aa300fbfa852e64afd7c65fceebff9/samples/csharp_dotnetcore/54.teams-task-module/Models/AdaptiveCardTaskFetchValue.cs
We are dealing with the code from a course that loads an image. We are trying to do this with an Emulator API 26 Play Store active We have no jpg pictures on the emulator. The Device File Explore will let us Upload a jpg. We have tried various folders with no luck.
Our question is where to Upload the jpg to in the Device File Explore?
Code is Kotlin and the upload method is posted below
fun onChooseImage(view:View){
val intent = Intent()
intent.type = "image/*"
intent.action = Intent.ACTION_GET_CONTENT
val chooser = Intent.createChooser(intent,"Choose Image for Habit")
startActivityForResult(chooser,CHOOSE_IMAGE_REQUEST)
Log .d(TAG,"Image was sent" )
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if(requestCode == CHOOSE_IMAGE_REQUEST && resultCode == Activity.RESULT_OK
&& data != null && data.data != null){
Log.d(TAG,"An Image WAS Choosen")
val bitmap = tryReadBitmap(data.data)
bitmap?.let {
ivIcon.setImageBitmap(bitmap)
Log.d(TAG,"We Updated and Read Bitmap")
}
}
}
private fun tryReadBitmap(data: Uri?): Bitmap?{
return try{
MediaStore.Images.Media.getBitmap(contentResolver,data)
}catch (e:IOException){
e.printStackTrace()
null
}
}
And we are using Cold Boot on the emulator.
We have looked at other posts that suggest you can not use the emulator camera to save pictures to the emulator. Does this mean we need a real device to test this code?
Grendel's answer is workable but I would like to provide a less intensive set of steps
1. Load the app in question
2. Open AVD manager and select the little down icon next to the Emulator your using
3. Click on Wipe Data (suggestion keep Emulator setting Quick Boot) <- other topic
4. Store your jpg in this path Storage->Self->Primary-DCIM
5. This is done by RIGHT click DCIM select Upload navigate to jpg
6. Close AVD manage
7. Run your app and select the same Emulator
It seems with the emulator you need to scan the emulator with Dev Tools BUT one other issue seems to pop up the cache for google play services and google play store needs to be cleared. In the processes of fixing this we tried so many fixes not sure of all the steps in order. As for where to upload the jpg that we are sure of use this path with
/mnt/sdcard/DCIM/water.jpg When you get to DCIM right click it and select Upload
Here is a link that may help HELP LINK
I have an native iOS sample app installed in my iPad and also my sample xamarin.Forms App installed. I want to open native iOS app from Xamarin.forms when clicked on button. I have set URL schema in my native iOS app in info.plist.
How do I open native app from xamarin.forms on click of a button. I already tried
var request = Device.OnPlatform(
string.Format("native app url"),
string.Format("native app url"),
string.Format("native app url"));
Device.OpenUri(new Uri(request));
but its not working.
It's basically how you are doing it.
var url = Device.OnPlatform(iOSUrl, androidUrl, winPhoneUrl);
Device.OpenUri(new Uri(request));
Be aware that each platform have some requirements in the way to url is configured and parameters are sent.
Let say to get the maps app open in each platform you would use these urls schemes:
// iOS doesn't like %s or spaces in their URLs, so manually replace spaces with +s
var iOSUrl = string.Format("http://maps.apple.com/maps?q={0}&sll={1}", name.Replace(' ', '+'), loc);
var androidUrl = string.Format("geo:0,0?q={0}({1})", string.IsNullOrWhiteSpace(addr) ? loc : addr, name);
var winPhoneUrl = $"bingmaps:?cp={loc}&q={name}";
var url = Device.OnPlatform(iOSUrl, androidUrl, winPhoneUrl);
Also you cannot open any arbitrary app unless you know its Url scheme.
Anyway, if the Device.OpenUri() doesn't fulfill your requirements you are good to create your own implementations using the native APIs.
Please go through the below link and attached photo
Link:-launch-an-app-from-within-another-iphone
I am using below code in xamarin forms
NSUrl request = new NSUrl("Camera://");
var canOpen = UIApplication.SharedApplication.CanOpenUrl(new NSUrl(request.ToString()));
if (!canOpen)
{ Task.FromResult(false); }
else
{
Task.FromResult(UIApplication.SharedApplication.OpenUrl(new NSUrl(request.ToString())));
}
I know this sounds weird. Is there any way we can open a URI from background tasks in Windows 10 Apps?
I have 2 requirements,
Talk to cortana and it will show you results based on the speech recognition, when user clicks on it, we cannot open the links in browser directly. Instead I am passing the Launch Context to the Foreground app and then using LauchUri I am opening the url in default browser.
Send toast notifications from the App, when user clicks on it, I have requirement to open a url instead opening an app. So, did the same, by passing the launch context to foreground app and then opening the url.
Both scenarios, it just opening url in browser. Here user experience is very poor that user seeing the app open for each action and then opening browser. Please throw some ideas if any possibilities.
thanks in advance.
For your second requirement, you can make Toast Notifications launch a URL!
If you're using the Notifications library (the NuGet package that we suggest you use), just set the Launch property to be a URL, and change the ActivationType to Protocol. You can also do this with raw XML, but that's error-prone.
You can also make buttons on the toast launch a URL too, since they also support ActivationType of Protocol.
Show(new ToastContent()
{
Visual = new ToastVisual()
{
BindingGeneric = new ToastBindingGeneric()
{
Children =
{
new AdaptiveText() { Text = "See the news" },
new AdaptiveText() { Text = "Lots of great stories" }
}
}
},
Launch = "http://msn.com",
ActivationType = ToastActivationType.Protocol
});
I am creating a firefox OS application, I want the user to be able to share a link through any application installed and eligible (facebook, twitter etc). I saw android has this kind of feature and firefox OS has it as well, as I saw it in one of it's built in applications. Went through Web API, didn't find a suitable match,
Any ideas how to do it?
This is the intended use of the Web Activity API . The idea is that applications register to handle activities like share. The Firefox OS Boiler Plate app has several examples of using Web Activities. In that example a user could share a url using code like:
var share = document.querySelector("#share");
if (share) {
share.onclick = function () {
new MozActivity({
name: "share",
data: {
number: 1,
url: "http://robertnyman.com"
}
});
};
}
Any app that handles the share activity will be shown allowing the user to pick the proper app to handle the share.