after several tests, i found the problem.
I use a TabbedPage.
to visualize the page correctly, I have to insert this instruction
android: TabbedPage.ToolbarPlacement = "Bottom"
'Bottom' and not 'Top'. with 'Top' the page remains empty.
Share Data Xamarin Forms

I have implemented the code to share data with my APP.
On Android, if my APP exists in the background, it works fine.
otherwise, if android closed my app, it won't load the controls in the form correctly.
What could be the problem?
-
Marco Salvatori 191 Reputation points
2021-10-14T14:53:31.973+00:00
1 additional answer
Sort by: Most helpful
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 19,971 Reputation points Microsoft Vendor
2021-09-08T07:56:17.6+00:00 Hello,
Welcome to our Microsoft Q&A platform!
I test the share feature with two apps, it works fine, I am so sorry I can't reproduce your issue, you could check your code according to the following steps.First, click the button to share in
ShareImageTwo
(An app to share)private async void Button_Clicked(object sender, EventArgs e) { await Share.RequestAsync(new ShareTextRequest { Text = "https://aka.ms/campus.jpg", Title = "ShareImageUrlString" }); }
Second, receive the text in
ShareImageOne
(means your app)- add
[IntentFilter(new[] { "android.intent.action.SEND" }, Categories = new[] { Intent.CategoryDefault }, DataMimeTypes = new[] { "text/plain" })]
toMainActivity.cs
- receive the text in
OnCreate
function and useMessagingCenter
to pass this text to Forms project.protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App()); if (this.Intent.Action == Intent.ActionSend) { var url = this.Intent.Extras.GetString(Intent.ExtraText); MessagingCenter.Send<string,string>("11","imageUrl", url); } }
- subscribe to this message and display
public MainPage() { InitializeComponent(); MessagingCenter.Subscribe<string, string>("11", "imageUrl", async (sender, arg) => { myLabel.Text = arg; await DisplayAlert("Message received", "arg=" + arg, "OK");// test imageurl = arg; await Navigation.PushModalAsync(new ShowImagePage(imageurl)); }); }
- new page to display the image
public ShowImagePage(string imageurl) { InitializeComponent(); myImage.Source = ImageSource.FromUri(new Uri(imageurl)); }
You also could upload your basic, minimal, reproducible project to github and attach the link here, then I will download and test it.
Best Regards,
Wenyan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. - add