Related
Hi I want to make an application using location, I found this tutorial
http://msdn.microsoft.com/en-us/library/dd938890.aspx#RetrievingLocationInformationthroughGPS
which looks very helpful but because I am new to visual studio I am having some problems.
1) is the article it says "This article includes complete sample code." but I cant find a download for all the code.
2) he only mentions referencing Microsoft.WindowsMobile.Samples.Location.dll which I have done but the class LatLong is still unknown
3) I made a sample program without the LatLong class just to experiment I get the following error on my device
"Microsoft.WindowsMobile.Samples.Location, Version=1.0.3448.25673, Culture=neutral, PublicKeyToken=null, or one of its dependencies, was not found
any idea what this means?
4) Could all my problems be because I am using visual studio 2005 and not 2008? I found a code project that looked really helpful but when trying to open it it says that it cant because it is from a newer version of the software, anything that can be done?
5) I find MSDN confusing for finding out what to reference to add a class for example this is the page for the LatLong class http://msdn.microsoft.com/en-us/library/cc514548.aspx
with the java online info the first thing you always see is where the class is found but it seems to be missing for this class. Other basig classes appear similar to java.
below is my sample code its basically taken from the article but I have commented out the references to LatLong and put in checks instead
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Samples.Location;
namespace DeviceApplication3
{
public partial class Form1 : Form
{
private Gps gps;
int count = 0;
public Form1()
{
InitializeComponent();
gps = new Gps();
gps.Open();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = (getGpsString());
}
private string getGpsString()
{
GpsPosition position = gps.GetPosition();
/*LatLong location = new LatLong();
if (position.LatitudeValid)
location.Latitude = position.Latitude;
if (position.LongitudeValid)
location.Longitude = position.Longitude;
if (position.HeadingValid)
location.Heading = position.Heading;*/
StringBuilder sb = new StringBuilder();
sb.Append("\n");
sb.Append("Latitude = ");
if (position.LatitudeValid)
{
sb.Append(position.Latitude.ToString() + "\n");
}
else
{
sb.Append("Not found yet\n");
}
sb.Append("Longitude = ");
if (position.LongitudeValid)
{
sb.Append(position.Longitude.ToString() + "\n");
}
else
{
sb.Append("Not found yet\n");
}
sb.Append("Heading = ");
if (position.HeadingValid)
{
sb.Append(position.Heading.ToString() + "\n");
}
else
{
sb.Append("Not found yet\n");
}
return sb.ToString();
}
}
}
Microsoft.WindowsMobile.Samples.Location.dll
is this file located in bin\debug and or \bin\release
?
and does it only give runtime errors or also compile time ?
no it compiles fine, can you see anything wrong with my code? The weird thing is the form comes up using the emulator but not on the device. Could it be because I have a custom rom that seems to have compact framework 3.5? I would assume it would be back compatible?
How have you deployed it to the device? Have you copied the .exe and the Location.dll?
one thing you could also test was if you could disable the stuff in the gps
and just run a program without it to verify that it's not missing net3.5's fault
heliosdev said:
How have you deployed it to the device? Have you copied the .exe and the Location.dll?
Click to expand...
Click to collapse
Hi thanks for this I didnt copy over the dll I'm very silly.
So what do you guys think about loading projects ment for vs 2008 in 2005 is this impossible ? or can i convert them somehow?
sure it's only the project and solution files which differ
add the cs files manualy and it should work fine
Use the same name to create the new project in vs2005 to have the same namespace.
You'll have to do some manual changes if the code uses c#3.0 .net 3.5 features.
Thanks guys your awesome,
very random and off topic but since your programming kings ill ask anyway,
I think I want to eventually work in the gaming industry, I'm close(3months) to finishing my MSc CompSci conversion course and I am looking for jobs, its quite aparent that most games companys don't want unexperienced people so do you guys have any ideas of places to apply for that will give the the necessary experience? btw I have no taught experience with C++ which I think is my biggest dissadvantage, I do know C and java quite well though and as you can tell just starting to play with C#.
your help is always appreciated.
well, continue with general programming (object oriented programming, ui development, database, network,...). There are so many different fields in software development!
For example take a look at the chapters of the books in the game programming gems series to see what (not only) gaming companies are working on. In general for beginning there is a lot of information online where you'll find tons of tutorials.
Try to get a profound base in programming.
Starting with your gps application, develop a gui, save/load the positions (database), visualize the points...
heliosdev said:
well, continue with general programming (object oriented programming, ui development, database, network,...). There are so many different fields in software development!
For example take a look at the chapters of the books in the game programming gems series to see what (not only) gaming companies are working on. In general for beginning there is a lot of information online where you'll find tons of tutorials.
Try to get a profound base in programming.
Starting with your gps application, develop a gui, save/load the positions (database), visualize the points...
Click to expand...
Click to collapse
Hi sorry for the late reply I upgraded to windows 7 last night to try and improve my rubbish laptop, seems to be a bit better btw,
anyway just want to say thanks for the advice. also my app will use google maps yahoo zonetag and windows live earth (or bing maps if thats what there calling it now) I think for some of thoes services I will need to pay to realease my app to the public even if its free but what about testers would I be able to give it to say 10 people?
From multiple sources (http://www.nextbestgeek.com/2010/12/30/getting-a-more-secure-windows-phone-7-app/, http://www.djawirlabs.com/1855/) i have heard that its possible to track down pirated apps by searching for a xml in the xap, the one thing i wonder, "have one person passed with this though submission process"?
Coder > submission process > add of "WMAppPRHeader.xml" > Marketplace ?
That above is the way i think it is, but if submission does not have "WMAppPRHeader.xml" in xap, the "checkers" will have a auto exit application if coded that way. Or is it?:
Coder > add of "WMAppPRHeader.xml" > submission process > Marketplace ?
Code:
public static bool IsHackedMarketplaceApp()
{
#if DEBUG
return false;
#endif
#pragma warning disable
try
{
var content = System.Xml.Linq.XDocument.Load("WMAppPRHeader.xml");
return false;
}
catch
{
return true;
}
#pragma warning restore
}
Without having a "is WMAppPRHeader.xml" present, if not "enter password" type setup, it won't be possible to have apps that work and pass certification.
With the password part, you can add a tester note in the submission forms with a password/method for installing that should get checked.
The alternative is the "IsTrial()" method with a lot of obfuscation surrounding any mentions of it.
Both of these methods are possible to get round with a moderate knowledge of C# and .Net Reflector, but with obfuscation it's a hell of a lot harder.
Obfuscation make it a lot difficult, but ive seen an obfuscator for pc that i used once, if we obfucate using that then reflector or any other program i tried to disassemble it crashed. Though i didnt check with hhd hex editor neo. for sure redgates reflector and another prog i used had no luck..
According to chevron group app piracy wont work when nodo update comes, not cox side loading wont work but the way they handle homebrew and marketplace app it seems
Hello,
I dont know if the title fits, so i gonna explain my Problem.
I want to Programm a Game With User Login. Sadly wp7 doesnt Support SQL api, so i cant make the User Management directly over sql.
So i got a Website with a working Login Formular. I want to link the wp7 textboxes with the textboxes of the Website which works with SQL.
Is there a simple way to get this working? Or does anyone have a better idea to get my User Management working?
Greatings win99
Sent from my HD2 using Board Express
Hmm... I can only suggest you to learn how to do http requests (and general programming of course). I hope u'll stop thinking in terms like "linking textboxes"
yeah, "linking" is maybe the wrong word
What exactly do you mean with "http request"?
I can program a bit html an php, which i could include in a "WebBrowser" control. This way i could use php with mysql, but i don't want to make a browser game.
Is there somethink like a "http database"? Cause i don't know yet any database based on http. And is there an API availible to do this requests from a panorama app?
Sorry for this basicly questions, but i'm just a hobby programmer and since now i just programme windows desktop projects, where i could easily use SQL.
Your "very basic question" requires a very long answer (sorry, but I don't have enough time. Also, I'm not an expert in SQL http communication). FYI, all communications between web page (and you can treat your WP7 page as a web page) and SQL server based on HTTP POST requests (but of course not on "linked textboxes"! ). So, try to google with words such as "WP7 SQL HTTP POST" - first five links possible will have all info you need (but you should understand "how everything works" first!)
ok, if i understand it correctly, this sound like instead of using "app<->SQL" i should use "appy<->http<->sql".
i will try to find some good tutorials and reply on success/ no success.
win98 said:
ok, if i understand it correctly, this sound like instead of using "app<->SQL" i should use "appy<->http<->sql".
i will try to find some good tutorials and reply on success/ no success.
Click to expand...
Click to collapse
Well, from the sounds of it, I am going to assume you networking and web API knowledge and maybe decent enough MySQL/SQL/Database knowledge, and possibly somewhat new to WP7 C#.NET (Don't take this personal or a lashing towards you, not the case, I mention it so I can be basic and to the point without assuming you know what references I make or offend you).
If you want an "out-of-the-box" easy solution, let's stop and go download RestSharp (http://restsharp.org). After you get it, visit: https://github.com/restsharp/RestSharp/wiki/Getting-Started, as this will give you a great example of HOWTO use this solution.
You also need to remember about the footprint, a 90MB limit (Max) on 256MB phones. Too big can cause some issues.
Also, another good option is SQLlite, probably one of the most popular, straight forward and well respected (I even use it on some projects). Should you choose to use it, go to http://sviluppomobile.blogspot.com/2010/07/wp7-sqliteclient-preview.html and read his Blog post, VERY informative and a Sample available for you to learn from as well.
If you really wanted to do this yourself, you could create an HTML page and do all your coding in it (e.g. Login Box) and use JavaScript as well, this way you grab the contents from your textbox(s) and send to the embedded web browser you load the HTML page in, hence scripting is available for WP7 but must enable scripting support and highly recommend to use IsolatedStorage and can invoke JS just as easy as:
window.external.notify("(Task)Param)");
So this should hopefully get you to where you want to be but if any of the above statement I made was true, I recommend out-of-the-box solutions for you.
Thanks,
Lance
lseidman said:
If you really wanted to do this yourself, you could create an HTML page and do all your coding in it (e.g. Login Box) and use JavaScript as well, this way you grab the contents from your textbox(s) and send to the embedded web browser you load the HTML page in, hence scripting is available for WP7 but must enable scripting support and highly recommend to use IsolatedStorage and can invoke JS just as easy as:
window.external.notify("(Task)Param)");
Click to expand...
Click to collapse
This is the way i planned to do it. How do you call it? For me it is hard to find a tutorial or book or something like that, cause i don't know which keyword to google
thanks anyway
win98 said:
This is the way i planned to do it. How do you call it? For me it is hard to find a tutorial or book or something like that, cause i don't know which keyword to google
thanks anyway
Click to expand...
Click to collapse
First and foremost, I appreciate your honesty which is why I will basically show you the way...
Well, if you wish to invoke JavaScript via WP7 you can, like below:
1). Open your Mainpage.xaml and find the grid and insert:
<phone:WebBrowser HorizontalAlignment="Left" Name="webBrowser1" VerticalAlignment="Top" Height="xxx" Width="xxx" IsScriptEnabled="True" ScriptNotify="webBrowser_callback" />
2). Make an HTML page, go in the HEADER section and type something like: "<SCRIPT LANGUAGE="JavaScript" src="HelloWorld.js"></SCRIPT>" and add a button that has a function to fire upon clicking + name the section like:
<h1 id='myName'>Hello World!</h1>
<form>
<input id="button" type="button" class="button-standard" style="width:200;height:100" value="Hello World!" onClick="HelloWorld()"/>
* Remove the Quotes from above...
3). Make a file called HelloWorld.js and put in something like:
function HelloWorld() {
window.external.Notify("Name");
}
function sets(val) {
document.getElementById('myName').innerHTML = val;
}
4). In your Mainpage.xaml.cs, find where you want to invoke the script/site and put in:
webBrowser1.Navigate(new Uri("http://lance.compulsivetech.biz/login", UriKind.Relative));
*Change the URI to your address, not my blog's fake login...
5). Since we are loading the site locally in Isolated Storage, go forth and type this in:
private void CreateDirOnStore(string strDir)
{
// Create a directory for local storeage.
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
if (!isoStore.DirectoryExists(strDir))
isoStore.CreateDirectory(strDir);
}
private void SaveFileToIsoStore(string strFileName)
{
// This will save the file to the isolated storage based on the string provided.
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
//remove the file if exists to allow each run to independently write to
// the Isolated Storage
if (isoStore.FileExists(strFileName) == true)
{
isoStore.DeleteFile(strFileName);
}
StreamResourceInfo sr = Application.GetResourceStream(new Uri(strFileName, UriKind.Relative));
using (BinaryReader br = new BinaryReader(sr.Stream))
{
byte[] data = br.ReadBytes((int)sr.Stream.Length);
//save file to Isolated Storage
using (BinaryWriter bw = new BinaryWriter(isoStore.CreateFile(strFileName)))
{
bw.Write(data);
bw.Close();
}
}
}
6). In your public MainPage() put:
this.Loaded += new RoutedEventHandler(Load_WebPage);
* Always put stuff after your Intialize call
7). We need to make a page load function as below (in xaml.cs):
void Load_WebPage(object sender, RoutedEventArgs e)
{
//Set the start folder of the widget and navigate to the start page
CreateDirOnStore("helloworld");
SaveFileToIsoStore("helloworld/index.html");
SaveFileToIsoStore("helloworld/helloworld.js");
webBrowser1.Base = "helloworld";
webBrowser1.Navigate(new Uri("index.html", UriKind.Relative));
}
8). Now we invoke the function as seen below:
void webBrowser_callback(object sender, NotifyEventArgs e)
{
//Use invokeScript to give to the web env.
webBrowser1.InvokeScript("eval", new string[] { "sets('txtName.Text')"});
}
Hope this helps, this is basically off the top of my head but should be pretty close to being right and Mango Compat.
Creating a WCF services that calls SQL will be the quickest way...about 30 minutes.
Hello!
Firstly, I don’t speak english very well. But I beg your indulgence.
I have some troubles with every GPS tracking apps I’ve installed on my Omnia W (I8350). While I start the tracking and locking my phone, it’s tracking quite well.
BUT, if I want to write a SMS or something. I have to press on the Windows-button to come out to the main menu, and the GPS-tracking will stop. But the time counter continues unaffected.
I think it’s a bit weird behavior. I have testet, Endomondo, Sports Tracker, SmartRunner, Runtastic. And all of these apps acts at same way.
Is this normally? Is it the OS, which stops the GPS-device, while the app is minimized?
It's the OS, yes. In theory, an app could continue GPS tracking in the background, but since that's not officially allowed (you'd need to mess with the APIs in ways Microsoft doesn't approve of) it wouldn't be allowed into the Marketplace.
@GoodDayToDie
Do you know any working hack that will allow app continue tracking in the background? Maybe some registry changing?
If app cannot get to Marketplace, it is not problem for me. I want to create GPS tracking in background only for myself.
At the max it will work with screen lock though Endomodo doesnt support but others do. And Yes its a problem with Windows Phone API not allowing intensive tasks to run in background.
May be a custom app can do which somebody can sideload but then its for one few people.
Well, the dehydration tweak that Jaxbot found (and yes, it's a registry change) allows an app to keep running in the background. That doesn't guarantee it will actually keep tracking - the app still gets notified that it's leaving the foreground, and a "well behaved" app might stop using resources like the GPS when it gets that notification - but it makes it possible. Normally I'd direct you to my MultiTaskToggle app, which is a very simple and user-friendly way to change this value, but it doesn't work on second-gen Samsung phones at this time.
GoodDayToDie said:
Well, the dehydration tweak that Jaxbot found (and yes, it's a registry change) allows an app to keep running in the background. That doesn't guarantee it will actually keep tracking - the app still gets notified that it's leaving the foreground, and a "well behaved" app might stop using resources like the GPS when it gets that notification - but it makes it possible. Normally I'd direct you to my MultiTaskToggle app, which is a very simple and user-friendly way to change this value, but it doesn't work on second-gen Samsung phones at this time.
Click to expand...
Click to collapse
I am pretty sure that just keeps it in memory, but not actually running. I downloaded the source code to see what it does and manually applied the registry change. It allows fast resume from any app, even if it was not recompiled for Mango. This is good for apps, such as Angry Birds, which would otherwise dehydrate, and need to restart. But, when using it, you can see that if you launch a bird, and then switch out. Wait a while. Then switch back to it. You can see that the launched bird has not moved since switching to a different app. It is possible that the app is suspending by responding to the fact that it is being pushed into the background.
Most apps that display time, or a timer that counts are not actually counting. What they do to display it get an initial time value when the timer starts. Then they get the time and subtract the initial time from it. So, an app that seems to count seconds, even when in the background is really just successfully get the current time and subtracting the original time before suspension. They may use a timer control to schedule the frequency that this calculation is made.
To verify, it would be good to test with a simple program that does something like:
Code:
[FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] TestCountApp
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]partial[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Form1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] : [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Form
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] {
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] Form1()
{
InitializeComponent();
}
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] i = 0;
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] btnStart_Click([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] sender, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]EventArgs[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] e)
{
timer1.Start();
}
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] timer1_Tick([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] sender, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]EventArgs[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] e)
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] val = 0;
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] try
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] {
val = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].Parse(tbText.Text.ToString());
}
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] catch[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Exception[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ex)
{
}
i++;
tbText.Text = i.ToString();
}
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] btnStop_Click([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] sender, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]EventArgs[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] e)
{
timer1.Stop();
}
}
}
of course the timer class might automatically suspend for Windows Phone.
So, a simple for loop might be better.
Code:
[FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] TestCountApp
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]partial[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Form1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] : [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Form
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] {
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] Form1()
{
InitializeComponent();
}
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] btnStart_Click([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] sender, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]EventArgs[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] e)
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff] for[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] i = 0; i < 60; i++)
{
tbText.Text = i.ToString();
System.Threading.[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Thread[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].Sleep(1000);
}
}
[/SIZE][/FONT][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] }
}
If it is background processing, you should see 59, after returning to the app. It will remain blank until the end.
[/SIZE][/SIZE][/FONT][/FONT][/SIZE][/FONT][/SIZE][/FONT]
GoodDayToDie said:
Well, the dehydration tweak that Jaxbot found (and yes, it's a registry change) allows an app to keep running in the background. That doesn't guarantee it will actually keep tracking - the app still gets notified that it's leaving the foreground, and a "well behaved" app might stop using resources like the GPS when it gets that notification - but it makes it possible. Normally I'd direct you to my MultiTaskToggle app, which is a very simple and user-friendly way to change this value, but it doesn't work on second-gen Samsung phones at this time.
Click to expand...
Click to collapse
Unfortunatelly it doesn't help, because OS is suspending app executing. OS is just keeping app in memory.
Anyway I can use background task in debug build with LaunchForTest method that will allow me execute background code as often I want. However background task cannot access fresh GPS data. It can only used cached data which is refreshed every 15 minutes. Is any way to force GPS to refresh it's data when using GPS from background agent?
OK, in reverse order:
@Mendoza32: You are quite incorrect; the change to the registry I was talking about actually causes the OS to *not* suspend apps. It can cause problems for some of them. In Mango, an app is *always* kept in memory when it's backgrounded. Apps that weren't recompiled for Mango can't take advantage of this and will do a full rehydrate anyhow, but they don't hve to (using a process listing, you can see that the suspended processes are still in memory). However, even with the tweak, a few things are cut off, like audio (and possibly GPS). See my response to JVH3 for more info...
As for a background agent, there's no official way. I think if you abuse one of the background audio decoder agent classes, you might be able to make an agent that runs in the background and can access the GPS. I haven't tried, though, and there's no chance of it getting into the Marketplace.
@JVH3: If you read the really old threads on the subject, you'll see that the app really does keep running in the background. For example, you can create an app that will pop a MessageBox (which always goes to the foreground) after 10 seconds, start it and immediately hit the Windows key. A few seconds later, you'll get the message box. More practically, you can use this hack to do things like run the WebServer app (any version) in the background, and browse it in the foreground on the phone's IE (pointing to 127.0.0.1). This would be impossible if the app were suspened, obviously...
As for Angry Birds, the game is in fact pausing the XNA update/render loop when notified that it's going into the background. In theory, this allows it to save the entire current game state, including the flying bird, such that when you resume the app (from dehydration, or so it thinks), that bird is exactly where it was and you've lost no progress. I suspect it is actually doing this. On the other hand, a game like Puzzle Quest 2 (which is rather poorly behaved regarding dehydration) quite obviously does *not* suspend the update/render loop. It's a turn-based game, so there is no gameplay problem, but there are certain real-time graphical effects that, when you "resume" the game, will all render simultaneously. Additionally, the phone will get quite warm and use a lot of battery (and other games will run slowly) because Puzzle Quest 2 still eating CPU and GPU time in the background.
GoodDayToDie said:
As for a background agent, there's no official way. I think if you abuse one of the background audio decoder agent classes, you might be able to make an agent that runs in the background and can access the GPS. I haven't tried, though, and there's no chance of it getting into the Marketplace.
Click to expand...
Click to collapse
I do not want put app in Marketplace. It's only for me
GoodDayToDie said:
@JVH3: If you read the really old threads on the subject, you'll see that the app really does keep running in the background. For example, you can create an app that will pop a MessageBox (which always goes to the foreground) after 10 seconds, start it and immediately hit the Windows key. A few seconds later, you'll get the message box.
Click to expand...
Click to collapse
Could you provide some sample code how to display this message box when app is in background? I tried this but without any luck. Maybe I'm missing something.
Did you have the no-suspend/dehydrate tweak enabled? It should be simple (event handler for a button or something:
Thread.Sleep(10000); MessageBox.Show("Alert from background app");
Thank you very much GoodDayToDie. I see how it works now. As long as GUI thread is blocked, then background threads keep working (also the GPS). One drawback is that I cannot go back to my app. It just keep displaying "Resuming...", but this is because GUI thread is blocked.
@GoodDayToDie
I was all wrong. Blocking GUI thread doesn't help in anything, because OS is killing app.
Please take a look at this sample code:
Code:
using System;
using System.Diagnostics;
using System.IO.IsolatedStorage;
using System.Threading;
using System.Windows;
using Microsoft.Phone.Controls;
namespace PhoneAppBackgroundTest
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
this.Loaded -= this.MainPage_Loaded;
this.DisplayLastUpdateTime();
}
private void buttonBackgroundThread_Click(object sender, RoutedEventArgs e)
{
ThreadPool.QueueUserWorkItem((s) =>
{
while (true)
{
this.UpdateLastUpdateTime();
Debug.WriteLine(DateTime.Now.ToString());
Thread.Sleep(1000);
}
});
}
private void buttonBlockGUIThread_Click(object sender, RoutedEventArgs e)
{
while (true)
{
Thread.Sleep(1000);
}
}
private string lastUpdateKey = "lastUpdate";
private void DisplayLastUpdateTime()
{
string value;
if (IsolatedStorageSettings.ApplicationSettings.TryGetValue<string>(this.lastUpdateKey, out value))
{
MessageBox.Show("last update time: " + value);
}
}
private void UpdateLastUpdateTime()
{
if (IsolatedStorageSettings.ApplicationSettings.Contains(this.lastUpdateKey))
IsolatedStorageSettings.ApplicationSettings.Remove(this.lastUpdateKey);
IsolatedStorageSettings.ApplicationSettings.Add(this.lastUpdateKey, DateTime.Now.ToString());
IsolatedStorageSettings.ApplicationSettings.Save();
}
}
}
Button "buttonBackgroundThread" is starting new background thread which updates settings value and display current time to Output window. When you press this button you will see in Ouput, that current time is displaying each second. When you use window key, then current time is no longer displaying in Output. So the thread gets suspended. When you go back to app it start to work again.
When you press on button "buttonBackgroundThread" and "buttonBlockGUIThread" and use window key, you will see that current time is keep displaying in Output. This works when you have debugger attached. If you follow this scenario on device without attached degubber you will see that app is getting killed by OS. To prove that app is displaing last update time at start.
So my question is: how to get managed threads keep running while app is in background? I'm attaching sample project, so you can test on your device and see that managed thread get suspended when you use window key.
Is maybe some way to use native threads that won't get suspended? I see your WebServer can run while app is in background. However you used native listeners.
I have android central and no one has responded so i figure i would try here.
I hava a college class for "intro to java"
And would you know it we have java files that i would LOVE TO EDIT ON MY TABLET
I have found java code viewers and allow some tiny amount of editing but NO ONE ALLOWS me to run code.
Example:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner kb= new Scanner(System.in);
double page;
double pheight;
double pweight;
double bmr;
int activity;
double burned;
String a1="Sedentary, little or no exercise, desk job.";
String a2="Lightly active (light exercise 1 to 3 times a week).";
String a3="Moderately active (Exercise 3 to 5 times a week.";
String a4="Very active (Exercise 6 to 7 times a week).";
String a5="Extra active (Exercises two times a day. Includes running marathon etc).";
System.out.println("What is your age?");
page = kb.nextDouble();
System.out.println("What is your Height (in inches)?");
pheight = kb.nextDouble();
System.out.println("How much do you weight(in pounds)?");
pweight = kb.nextDouble();
bmr= 66 + 6.2*pweight + 152.4*pheight - 6.8*page;
System.out.println("Please enter the correct numbe rthat goes with our life style.");
System.out.println(a1+"|1.2|");
System.out.println(a2+"|1.375|");
System.out.println(a3+"|1.55|)");
System.out.println(a4+"|1.725|");
System.out.println(a5+"|1.9|");
activity =kb.nextInt();
burned = bmr*activity;
System.out.println("Your age is :"+ page);
System.out.println("Your height is :"+pheight +"in.");
System.out.println("You weight is :"+pweight+"lb.");
if (activity== 1.2)
{
System.out.println("The activity factor -"+a1);
}
if (activity== 1.375)
{
System.out.println("The activity factor -"+a2);
}
if (activity== 1.55)
{
System.out.println("The activity factor -"+a3);
}
if (activity== 1.725)
{
System.out.println("The activity factor -"+a4);
}
if (activity== 1.9)
{
System.out.println("The activity factor -"+a5);
}
System.out.println("The bmr is-"+ bmr);
System.out.println("You burned "+ burned);
}
}
No app that i can find can you this simple program and thus making my college class EXTREMELY hard
Please some one help
Sent from my GT-N8013 using xda app-developers app
Your Java instructor will surely have told y'all about compilation to bytecode with the JDK, running bytecode in the JVM, etc. There is no Java Virtual Machine (not to be confused with the Dalvik virtual machine) for Android, at least that I know of.
Your best options for running Java code "on" your tablet are:
SSHing to a server where you can compile your Java programs on the command line, presumably through some linked storage enabling you to do your editing on Android.
Editing your Java programs on your tablet and then using a website like http://ideone.com to run your code.
Honestly, though, this is going to be much more cumbersome than working on a laptop or desktop.
EDIT: See also this thread, especially the last post: http://forum.xda-developers.com/showthread.php?t=1452666
If you're comfortable with working in a terminal, I highly recommend TerminalIDE. It's what I used for the first term of Java programming in college last year (in fact, I think it was the only app that allowed Java compilation at the time).
There's also AIDE which is great for developing Android apps, but probably not so much for following along in class, since for even basic GUI stuff, you'd have to figure out how to do it the Android way (which is very different from swing), and I'm not sure how it'd handle console apps (maybe fine, but then you'd have to deal with switching windows to a terminal emulator, such as TerminalIDE, anyway... probably best to just use TerminalIDE from the start).