Issue
I have a pdf Form stored in my xamarin android app resources. I want that the app user can extract the Form from the resources and fill it.
I found some samples in nativ android, but I cannot adapt it to Xamarin. I need to get the resource file to an input stream, but do not succeed.
Solution
First, when you have a file in raw folder of the Resource folder of Android project, you could open a data stream for reading a raw resource.
I add a file named file1 in raw older for reference.
var stream = Resources.OpenRawResource(Resource.Raw.file1);
If you want to read the string from the stream, you could use the code below.
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
string line=reader.ReadLine();
And then, if you want to get this in Xamarin.Forms, you could use DependencyService. For more details, check the link below. https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/introduction
Answered By - Wendy Zang - MSFT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.