Posts

Showing posts with the label xamarin.android

How to get list of downloaded files from External File Directory in xamarin.forms?

How to get list of downloaded files from External File Directory in xamarin.forms? I am working in xamarin.forms. I want to download file and also want to show all the downloaded files as a list. I want to implement this feature in both android and IOS. I took reference from below link to download files. It was successfully implemented. https://forums.xamarin.com/discussion/71203/how-to-download-a-file-in-xamarin-forms-and-store-it-in-the-device-storage But Now I want to list out all the downloaded files which are available in that folder. I did not any solution for the same. For android : public void Downloaded() { CrossDownloadManager.Current.PathNameForDownloadedFile = new Func<Plugin.DownloadManager.Abstractions.IDownloadFile, string>(file => { string fileName = Android.Net.Uri.Parse(file.Url).Path.Split('/').Last(); return Path.Combine(ApplicationContext.GetExternalFilesDir(Android.OS.Environment.DirectoryDownlo...

Xamarin.Android and RecordAudio: how to combine file writing and other task

Xamarin.Android and RecordAudio: how to combine file writing and other task I develop a Xamarin.Android app where I need to record an audio file in a .wav and to display the related spectrogram in the same time. I'm able to perform the 2 tasks separately but not to combine them. I use an AudioRecord to record the sound through the microphone: AudioRecord public async Task StartRecording() { audioRecord = new AudioRecord(AudioSource.Mic, 44100, ChannelIn.Mono, Android.Media.Encoding.Pcm16bit, bufferSize); if (audioRecord.State == State.Initialized) audioRecord.StartRecording(); isRecording = true; recordingThread = new System.Threading.Thread(new ThreadStart( WriteAudioDataToFile )); recordingThread.Start(); } The file writing is done in WriteAudioDataToFile() and works fine: WriteAudioDataToFile() private void WriteAudioDataToFile() { byte data = new byte[bufferSize]; string filename = GetTempFilename(); FileOutputStr...

Xamarin android notification for events

Xamarin android notification for events I'm working on a xamarin.forms application in .net standard 2.0. I have a list of events in my sqlite db with each event having starting and end time. Now, I want to show an alert to the user when ever any event is going to start in 5 minutes and when it's started and when its ended (3 alerts for each event). My approach : The issue is how can I show the alert on the exact time for the event stored in the db for start and end. Between 2 alarm managers if my evemt is occurring then I'm not able to show the alert on the exact time. Thanks in advance. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Different look/style for specific item on BottomNavigationMenu

Image
Different look/style for specific item on BottomNavigationMenu I am currently building a Xamarin Android application, and I am trying to customize the BottomNavigationView. I would like to be able to change the style of a specific menu item in the BottomNavigationView from the following: To this style: I have had a look at the following question: Different look/style for specific menu item on ActionBar but it seems more targeted towards the action bar rather then the bottom navigation. I'm guessing this would either need a custom control implemented or use of reflection to achieve the desired result? Any third-party libraries that implement this sort of functionality, aren't particularly helpful as majority of them are written for native android and not xamarin. Any help in either Xamarin C# or Native Java (that I could convert) would be great thanks. Currently I tried setting a custom action layout on the menu item programmatically: var nav = FindViewById<BottomNavigationVi...

How to change ListView item text color in Xamarin.Android?

Image
How to change ListView item text color in Xamarin.Android? I have a simple ListView like below : - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ListView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/asimplelistView1" /> I am binding this ListView by array ArrayAdapter using: ArrayAdapter<string> arrayAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleExpandableListItem1,mItems); My app secondary text color is white(#FFFFFF) and theme is android:Theme.Material.Light.. My problem is: I need to change item text color to gray because items text color is not visible on white background. In Java we can do like below: // Create a List from String Array elements List<String> fruits_list...