Image cannot display device picture.
See original GitHub issueDescription
Image cannot display device picture which in “/data/user/0/app/cache/xxx.png”, it’s display as blank.
And my code as follow:
MainPage.xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp1.MainPage">
<StackLayout>
<Button Clicked="Button_Clicked" Text="Pick"></Button>
<Image x:Name="Img" Source="dotnet_bot.png" WidthRequest="300" HeightRequest="300" ></Image>
</StackLayout>
</ContentPage>
MainPage.xaml.cs
namespace MauiApp1
{
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
private async void Button_Clicked(object sender, EventArgs e)
{
var photo = await MediaPicker.PickPhotoAsync();
var newFile = Path.Combine(FileSystem.CacheDirectory, photo.FileName);
using (var stream = await photo.OpenReadAsync())
using (var newStream = File.OpenWrite(newFile))
await stream.CopyToAsync(newStream);
await DisplayAlert("newFile", newFile, "OK");
Img.Source = newFile;
}
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>
</manifest>
BTW, is there any way to pick images from gallery?
Steps to Reproduce
- Create a File > New .NET MAUI App
- Replace
MainPage
ansAndroidManifest
with the code - connect the local device
- run
Version with bug
Release Candidate 1
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
API 30
Did you find any workaround?
Affected platforms
: Only tried on Android
Relevant log output
I don't know how to get it, maybe the official can give a tutorial, thanks a lot.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
ImageView displaying in layout but not on actual device
When I choose to view the Graphical Layout of the UI it displays the imageview correctly at the bottom of the activity. However,...
Read more >Message: windows photo viewer can't display this picture ...
Under Devices tab tick "Use My Settings" for this device. Highlight and delete the profile associated with this device. Check the images.
Read more >How to fix pictures not showing in gallery of Android device
How to fix pictures not showing in gallery of Android device | Images missing from gallery Subscribe to my channel: ...
Read more >How to Fix if Images are Not Showing in the Gallery of Android ...
In case if you want to move this photo to the gallery what you do is ... I don't have the same display...
Read more >How to fix picture not showing up in phone gallery - YouTube
I can't see photos phone gallery -fixed Subscribe to my Channel: ... Photo Not Show In Gallery Samsung || Pictures / Pics Are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Perfect! In RC3, it works as expected. And I think this issue can be closed. Thank you!
Hi @zxyao145. We have added the “s/needs-info” label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.