|
Did you try these suggestions[^]?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have an existing sqlite database in the android project under Assets.
I use the following to copy the database to the application personal folder
public async Task<string> GetDBPathAndCreateIfNotExists()
{
string databaseName = "DBQDive.db3";
var docFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var dbFile = Path.Combine(docFolder, databaseName);
if (!File.Exists(dbFile))
{
FileStream writeStream = new FileStream(dbFile, FileMode.OpenOrCreate, FileAccess.Write);
await MainActivity.Instance.Assets.Open(databaseName).CopyToAsync(writeStream);
}
return dbFile;
}
The problem is that even after uninstalling the app from the phone
if (!File.Exists(dbFile)) ALWAYS find a database file and therefore never copies the new database because the database has been created by a previous installation.
How can I detect if this is the first time the app is run so I can delete the database before it should be copied over?
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Just a guess, but when you reinstall the app, the allowBackup element in the manifest may be restoring your database.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Thanks for the hint - had nothing to do with the problem
The issue was with precedence, I was creating a SQLite database in the DAL base class BEFORE copying over the existing DB.
new SQLiteAsyncConnection(FilePath);
This actually creates an empty database in that location and it was called prior to the copy from android.
Last major issue nailed before I can deploy to the UAT people Yah!!!
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I am trying to implement a MVVM ContentPage with a ListView that needs to bind to populated generic list of XML model objects in a ViewModel but the binding fails. The code that is shown calls an API that does return a valid list of XML data. The same code works fine when the binding is done directly in the code behind of the XAML Xamarin contentpage by setting the ItemSource in the codebehind. As said, the problem only happens when trying to pass the ListView through the ViewModel assigned to the contentpage. I have stepped through the code in the ViewModel and the ListView is populated successfully but the binding just doesn't work. I have other controls that are on the page not shown that the model binding does work for but the only control that doesn't work is the ListView. The code is shown below:
ViewModel:
namespace RestDemo.ViewModel
{
public class ViewModel : INotifyPropertyChanged
{
public ViewModel ()
{
GetRequest();
}
List<XmlPizzaDetails> _objPizzaList;
public List<XmlPizzaDetails> ObjPizzaList
{
get { return _objPizzaList; }
set
{
if (_objPizzaList != value)
{
_objPizzaList = value;
OnPropertyChanged("ObjPizzaList");
}
}
}
public async void GetRequest()
{
if (NetworkCheck.IsInternet())
{
Uri geturi = new Uri("http://api.androidhive.info/pizza/?format=xml");
HttpClient client = new HttpClient();
HttpResponseMessage responseGet = await client.GetAsync(geturi);
string response = await responseGet.Content.ReadAsStringAsync();
ObjPizzaList = new List<XmlPizzaDetails>();
XDocument doc = XDocument.Parse(response);
foreach (var item in doc.Descendants("item"))
{
XmlPizzaDetails ObjPizzaItem = new XmlPizzaDetails();
ObjPizzaItem.ID = item.Element("id").Value.ToString();
ObjPizzaItem.Name = item.Element("name").Value.ToString();
ObjPizzaItem.Cost = item.Element("cost").Value.ToString();
ObjPizzaItem.Description = item.Element("description").Value.ToString();
ObjPizzaList.Add(ObjPizzaItem);
}
Progress = false;
}
}
}
}
XAML
Model Binding portion:
ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xlocal="clr-namespace:RestDemo.ViewModel"
xmlns:local="clr-namespace:RestDemo"
xmlns:Views="clr-namespace:RestDemo.Views"
x:Class="RestDemo.XmlParsingPageBehavior">
<ContentPage.BindingContext>
<xlocal:ViewModel />
</ContentPage.BindingContext>
Grid Binding Portion
<Frame Margin="5, 5, 5, 5" Grid.Row="2" Grid.Column="1" BackgroundColor = "Cyan">
<ListView x:Name="PizzaListView" ItemsSource="{Binding ObjPizzaList}" Margin="5, 0, 5, 0" Grid.Row="2" Grid.Column="1" HorizontalOptions="FillAndExpand" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid HorizontalOptions="FillAndExpand" Margin="0,0,0,0" Padding="20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Text="{Binding Name}" HorizontalOptions="StartAndExpand" Grid.Row="0" TextColor="Blue" FontAttributes="Bold"/>
<Label Text="{Binding Cost}" HorizontalOptions="StartAndExpand" Grid.Row="1" TextColor="Orange" FontAttributes="Bold"/>
<Label Text="{Binding Description}" HorizontalOptions="StartAndExpand" Grid.Row="2" TextColor="Gray" FontAttributes="Bold"/>
<BoxView HeightRequest="2" Margin="0,10,10,0" BackgroundColor="Gray" Grid.Row="3" HorizontalOptions="Fill" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Frame>
|
|
|
|
|
Try removing the Frame and addition decorations and start with a basic LV
<ListView x:Name="PizzaListView" ItemsSource="{Binding ObjPizzaList}" >
You do not need the grid R/C in the listview
Ah think I have got it - your List should be an ObservableCollection<>.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I have it working. Yes ObservableCollections are the way to go but generic Lists are fine as well. The problem is that when the Model is bound the WebService call has not completed so when the List property is bound it is still null. Even when updated at this point the ObservableCollection won't work because it has not been seeded. The solution is to seed the ObservableCollection, or List, on the Page's OnAppearing event and bind the ViewModel as the BindingContext in this event. My solution is below:
protected override async void OnAppearing()
{
var vm = new ViewModel.ViewModel();
if (vm == null)
return;
HttpClient client = new HttpClient();
HttpResponseMessage responseGet = await client.GetAsync(vm.Geturi);
string response = await responseGet.Content.ReadAsStringAsync();
var _objPizzaList = new ObservableCollection<XmlPizzaDetails>();
XDocument doc = XDocument.Parse(response);
vm.GetRequest(doc);
this.BindingContext = vm;
}
|
|
|
|
|
Using MVVM I have a fairly typical data entry form where the user selects a Site which, in the ViewModel, creates a new SiteRisks record and pre populates the ID fields, the user then selects a bunch of values from pickers.
A typical picker in XAML
<Label Text="Surface Conditions:"
Style="{StaticResource Label1Style}" />
<Picker Title="Select"
ItemsSource="{Binding SurfaceList}"
SelectedItem="{Binding SelectedSiteRisks.SurfaceID, Mode=TwoWay}"
ItemDisplayBinding="{Binding Surface}" />
Where SelectedSiteRisks.SurfaceID is the field on the object where the value will be stored. This works from the View > VM and the correct value is stored in the SelectedSiteRisks object but when I create a new SelectedSiteRisks object in the VM and preload the SelectedSiteRisks.SurfaceID the view does not reflect the changed value.
OR
Do I need to have a selecteditem for each picker and manually update the SelectedSiteRisks object.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
hi there,
I am writing a mobile app to allow music to be played but facing problem to link it . any suggestion where could be the mistake ? thank you
|
|
|
|
|
Hello
i have a web service which uploaded in my host.
now i wants to call it in a B4A.
this webservice returns only string "Hllo world".
but when i call it by bellow commands of B4A, it return all html codes of page.
why?
code in B4A :
Dim job1 As HttpJob
job1.Initialize("", Me)
job1.Download("http://www.agrp.somee.com/MYServices2.asmx?op=HelloWorld")
Wait For (job1) JobDone(job1 As HttpJob)
If job1.Success Then
a=job1.GetString
Msgbox(a,a)
End If
job1.Release
Thanks
|
|
|
|
|
I have a requirement where the user needs to enter a report, very structured, pick this, select that enter a value and it looks up related info etc.
The point is that the device will NOT be connected to the internet and will not have phone service (think fishing boat in the middle of the ocean), I think this rules out a web application as it will require a local database.
The app should be both android and apple accessible. Synching the databases to a central server should be trivial.
What platform would service this requirement.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Ionic with Angular comes to mind...
|
|
|
|
|
Does not seem to give any benefits over Xamarin forms, as I have a visual studio and WPF background I am going with that, thanks for the input.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Good Day All
i have images in a Listview ,i tried this on a normal Listview and also Telerik , it behaves the same. The Tab event is not fired consistently sometimes when i tap the images they dont respond to the Tap.
Here is my xaml
<telerikDataControls:RadListView Grid.Row="1" x:Name="lstfun" BackgroundColor="Transparent">
<telerikDataControls:RadListView.ItemTemplate>
<DataTemplate>
<telerikListView:ListViewTemplateCell>
<telerikListView:ListViewTemplateCell.View>
<Grid Padding="8,0,8,10" RowSpacing="0">
<Grid Padding="1" BackgroundColor="#e1e1e3" RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="53" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Padding="0" BackgroundColor="#e4e4e4">
<StackLayout>
<Label Text="{Binding FUN_NAME}" FontFamily="Ubuntu" FontSize="14" TextColor="#9e9ea0" />
<Image Source="HeaderBackground.png" HeightRequest="100" Aspect="AspectFill"/>
<Label Text="{Binding DESCRIPTION}" FontFamily="Ubuntu-Medium" FontSize="14" TextColor="#3c3947" />
</StackLayout>
</Grid>
<Grid Grid.Row="1" BackgroundColor="#ffffff" RowSpacing="0">
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="15" />
<RowDefinition Height="4" />
<RowDefinition Height="15" />
</Grid.RowDefinitions>
<pre>
<StackLayout Padding="-25,12,0,0" Spacing="-100" Orientation="Horizontal">
<StackLayout Orientation="Vertical" >
<Image Source="chat.png" InputTransparent="false" HorizontalOptions="Center" HeightRequest="35" WidthRequest="150" >
<Image.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Tapped="TapGestureRecognizer_Tapped_4"/>
</Image.GestureRecognizers>
</Image>
</StackLayout>
<StackLayout Orientation="Vertical">
<Image Source="love.png" x:Name="imglike" InputTransparent="false" HorizontalOptions="Center" HeightRequest="35" WidthRequest="150" >
<Image.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Tapped="TapGestureRecognizer_Tapped" />
</Image.GestureRecognizers>
</Image>
</StackLayout>
<StackLayout Orientation="Vertical">
<Image x:Name="imgfunin" Source="funin.png" InputTransparent="false" HorizontalOptions="Center" HeightRequest="35" WidthRequest="150" >
<Image.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Tapped="TapGestureRecognizer_Tapped_1"/>
</Image.GestureRecognizers>
</Image>
</StackLayout>
<StackLayout Orientation="Vertical">
<Image Source="Fakenews.png" InputTransparent="false" HorizontalOptions="Center" HeightRequest="35" WidthRequest="150" >
<Image.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Tapped="TapGestureRecognizer_Tapped_2" />
</Image.GestureRecognizers>
</Image>
</StackLayout>
<StackLayout Orientation="Vertical">
<Image Source="share.png" HorizontalOptions="Center" InputTransparent="false" HeightRequest="35" WidthRequest="150" >
<Image.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Tapped="TapGestureRecognizer_Tapped_3" />
</Image.GestureRecognizers>
</Image>
</StackLayout>
</StackLayout>
</Grid>
</Grid>
</Grid>
</Grid>
</telerikListView:ListViewTemplateCell.View>
</telerikListView:ListViewTemplateCell>
</DataTemplate>
</telerikDataControls:RadListView.ItemTemplate>
</telerikDataControls:RadListView></pre>
and the event handlers for my images TapGestureRecognizer_Tapped
<pre>private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
{
DisplayAlert("", "Like Tabbed", "Ok");
}
private void TapGestureRecognizer_Tapped_1(object sender, EventArgs e)
{
DisplayAlert("", "Funin", "Ok");
}
private void TapGestureRecognizer_Tapped_2(object sender, EventArgs e)
{
DisplayAlert("", "Fake News Tabbed","Ok");
}
private void TapGestureRecognizer_Tapped_3(object sender, EventArgs e)
{
DisplayAlert("", "Shareout Tabbed", "Ok");
}
private void TapGestureRecognizer_Tapped_4(object sender, EventArgs e)
{
DisplayAlert("", "Comment Tabbed", "Ok");
}</pre>
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vimalsoft.com
vuyiswa[at]vimalsoft.com
|
|
|
|
|
any one help me code of prayer five time in android studio?
|
|
|
|
|
It doesn't quite work like that.
We do not do your work for you.
If you want someone to write your code, you have to pay - I suggest you go to Freelancer.com and ask there.
But be aware: you get what you pay for. Pay peanuts, get monkeys.
The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".
So either pay someone to do it, or learn how to write it yourself. We aren't here to do it for you.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Although I had the idea of doing the same thing, in order to force my systems to prevent me from using them during the prayer time. But, somehow I could not finish it at all.
Anyhow, the best approach to solving this problem is using the Android Alarm system. Set an alarm in the device, and it will remind you, you can do that programmatically. Unlikely it is that your Android will know when it is the prayer time for you. So you will have to feed it yourself. Since we are able to do this programmatically, we can utilize an API or a service provider that gives the prayer time for a certain location. Then you can blend the time with the location APIs in Android, and receive the information about that time.
Lastly, just make sure to follow the time and offer the prayer. Good luck!
Schedule repeating alarms | Android Developers
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I just have a quick question about designing a ride sharing app. When you program an app how close to the copyright laws can you get. I know Uber's algorithms have copyrights and so do Lyft's. So how hard is it to program a ride sharing app without getting sued. Has anyone encountered this? I guess I would have to hire a copyright attorney. Any advice would be great.
|
|
|
|
|
ericbruhaha wrote: I guess I would have to hire a copyright attorney. Exactly. This is a technical forum, not a legal one.
|
|
|
|
|
the first thing to do is to contact your legal attorney, then you find a way of incorporating the information provided by your attorney into the app.
|
|
|
|
|
The chance of you duplicating their systems and violating copyright laws is near zero, unless you own some of their code. It's also not like you're not allowed to use a for-loop since it occurs in their code.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi Eddy, So are you telling me that if I duplicate an app in my own code then I have nothing to worry about. Meaning I just do the design in a similar way. I'm assuming that is exactly what Lyft did to Uber. Am I correct in thinking this way?
|
|
|
|
|
Not just the app, but everything, including graphics for the buttons. Then no, you don't have to worry.
Swap your idea with other software, and ask the question again; someone built a [database server|chat application|space game] and you want to build one too. Copyright means you're not allowed to sell their code as if it is yours, doesn't mean you're not allowed to build games.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Great! Thanks for the information
|
|
|
|
|
You're welcome.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|