Non android java java files - Galaxy Note 10.1 Themes and Apps

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).

Related

Programming/Development question

I hope this doesn't get lost in the sea of other questions.
Im working on a little program for my Visual Basic 08 class. Im going a bit further with it and making a windows mobile version of it. (currently using the WinMo 5 SDK) The program works fine in the windows platform, however when i copied the code over to the WinMo version, there was a few issues with the code. Most of it i manage to find the new syntax for and get it working on the WinMo emulator, however there is one problem that persists. TabControl.focus. This function does not seem to work in the WinMo development. Any Code i input that looks for what tab has focus, is ignored, like it doesn't know to look for the focus. Here is what im trying to do.
I have a program, with 2 tabs, and one button. I need that one button to execute two separate code blocks, depending on which tab is active. However i cannot get it to recognize, or do not know the proper function to get it to see which tab has focus, and execute the proper code accordingly.
Now, the simple fix for this would to just make another button, and place one each inside the tab, but i wanted to avoid that for as much as possible, and since it workers fine on the windows end, i know there has to be a way to get it working on the winmo end. By the way, im doing this in VB because im learning VB for a class, and the more coding practice i get the better ill do in class. Im sure there is a better way to do this in C# or whatever else.
Anyone know the workaround for this?
Im currently using Visual Studio 2008 Pro with the WinMo 5.0 SDK.
Your two tab pages are already part of a tabcontrol object. Use that to find the active tab with its property tabControl1.SelectedIndex This will return a zero based index integer for each tab paged attached to it. The object names used here are the default ones created by the IDE
Sorry, I only code in c#, but the VB code will be almost identical.
In the code for the button click event -
if(tabControl1.SelectedIndex == 0)
{
// tabPage1 active
}
else
{
// tabpage2 active
}
c sharp's double equals is the same as VB's single equals, in the sense that it means 'is equal to'.
There is not "active" property in vb (atleast not in vb mobile code) so that doesnt work
Im somewhat fimiular with c++, so i can atleaast understand the code when you put it in C format, but i have a bit of trouble converting C code to vb format. In this case, in normal (non-mobile) the .focus would be enough to make it work...
Here is what i tryed to make work..
Code:
'Changes what the "Roll" button does depending on which program tab is selected.
Select Case True
Case xTabPageCombatRoll.Focus
Call RollCombat()
Case xTabPageRandomRoll.Focus
Call RollRandom()
Case Else
MessageBox.Show("The Tab Control code didnt work")
End Select
both tab pages are part of xTabPageCombatRoll object
I'd suggest asking Development questions in the Dev&Hack section.
(yes, new rules)
Here's the screen shot and the c# application to go with it. Its in VS2005 but VS2008 will open it and convert the solution and project files to 2008 format. Once that happens VS2005 will not be able to open it.
The lines starting // in the code in the previous post above are comments. Same as VB's ;
thanks steph, i have 2005 installed along with 2008 so i just ran 05 . That code does work. But i still cant find anyway to translate that into VB (as .SelectedIndex is not valid in VB code)
ugh.. the more i work with VB the more i like C based code. But im in a VB class so im trying to keep doing stuff in VB so i can pass the class.
SelectedIndex is a property of the TabControl, a .NET framework object It does not matter which language you use to access it. VB, C#, C++, take your pick .
To prove the point here is the same project in VB. I had had to do this on another machine, as I only have C++ and C# installed on this one.
It only had the WM 2003 SDK on it. If your machine has the .NET CF 2.0 the .EXE should work, if you drop it on your device.
Another trick is to use Red Gate's .NET Reflector. If you point it at the original exe generated by the C# project in the previous post above, it decompiles it in C# as
Code:
private void button1_Click(object sender, EventArgs e)
{
switch (this.tabControl1.SelectedIndex)
{
case 0:
this.label1.Text = "Page1 is active";
break;
case 1:
this.label1.Text = "Page2 is active";
break;
}
}
If you decompile it as VB instead you get :
Code:
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Select Case Me.tabControl1.SelectedIndex
Case 0
Me.label1.Text = "Page1 is active"
Exit Select
Case 1
Me.label1.Text = "Page2 is active"
Exit Select
End Select
End Sub
Ahh..
I got it to work now.. My problem was i wasnt specificly using Case 0 and Case 1, but instead using Case Tabpage1, and Case Tabpage2, which wasn't working.
Thank you VERRRY much.. The program is working like it should now and it makes me verry happy

[Q] Open a Programm twice parallel?

Hi everybody,
is it possible to open a programm twice parallel? I want to open the coreplayer twice, one time for music and another time for audiobook. Is that possible?
thx, mic
It's probably not too hard to write a script for it.
trying talking to either vijay or oldsap.
Depends on the code in the program itself. In the shell code created by Embedded C++ in the InitInstance function there is the following code:
Code:
hWnd = FindWindow(szWindowClass, NULL);
if (hWnd)
{
// set focus to foremost child window
// The "| 0x01" is used to bring any owned windows to the foreground and
// activate them.
SetForegroundWindow((HWND)((ULONG) hWnd | 0x00000001));
return 0;
}
In other words when the application starts, it looks for another active process with the same name as itself. If it finds one, it activates it, then kills itself.
thx for try to help me - that means it is not possible?
The original PPC programming guidelines by Microsoft stipulated that only one copy of a program should be running at any one time. In later versions of Windows CE/PPC a lot more processes are allowed to run simultaneously. They may have changed their tune over this since. Try and launch it twice, then go to Settings->System->Memory and see if there is more than one copy in Running Programs. If there is only one, then I'm afraid the answer is no.
P.S. If you create a Windows Mobile Win32 program in C++ under Visual Studio 2008, it still has the process checking code in it by default.

Wanting to develop for WM haivng some problems

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?

[Q] Basic Java Programming - pi as a float

Forgive me if this has been asked, but I searched for pi and Math.PI and couldn't find anything relevant.
I am new to programming, so I am starting out with basic Java.
Problem as follows:
input:
a number which is a radius​output:
area and circumference of the circle with input as radius
volume and surface area of the sphere with input as radius​
I got a working class, but when I attempted to change the variables to floats, in the interest of learning, it errored out. The reason is that Math.PI yields a double. I tried: float pi = Math.PIF​ That doesn't work. The only way I was able to have a working class using floats, I had to initialize pi as follows:
pi = 22/7F​Is there a way to use Java's Math.PI as a float?
just out of curiousity, since i'm taking a java class now.
why would you want to change math.pi into a float?
edit:
don't have a working copy of the java ide yet but, have you tried var = (float)math.pi?
As I said in the post:
in the interest of learning​
When I begin to write larger programs, if I need to save memory, need to use pi, and won't be hindered by the inaccuracy of float calculations, then I will want to know how to do this.
just finished installing my java ide and netbeans.
and well, to change Math.PI into a float, you can do
final float var = (float) Math.PI
Since you said you're new, final means it can't be overridden (ie, change numbers) and is optional per your needs.
if you want to check it;
float fpi = (float) Math.PI;
System.out.println("Floated Pi " + fpi);
System.out.println("Normal Pi " + Math.PI);
also, if you want a java pdf, send me a pm and i'll send you the link
That worked. Just so you know, with an input of 1, the only value which was off was that of the surface area of the sphere. 12.57 when it should be 12.56. This may be due to my formatting the output to 2 decimal places, or to the inaccuracy of the float. I'll cross that bridge when I come to it.
a spheres radius of 1's surface area is (float)12.566371. so your 12.57 seems correct. Its been fun, but its 5am here. time for bed
I think I had used 3.14 on a calculator to come up with 12.56. That would definitely not be the best number to use. I was tired. Thanks for the help though.

Link contact adress to Nokia Drive

I use my7rom on my Omnia 7.
Is there anyway to link a contacts adress to Nokia Drive instead of Maps (stock wp7 app). It would be much more practical if Nokia Drive opened a navigation session instead.
Anyone up for the challenge? A reg-tweak perhaps?
// Manneman
Skickat från Windows Phone 7.8
There's two parts here. The first is identifying the correct "filetype" or URI scheme that is used for navigation. That shouldn't be too hard; a little digging in HKCU should reveal it. We already know about ones like callto: and http: and I'm actually (slowly) working on an app to allow people to easily change them. The second part is finding the correct command to load that address or route in the Nokia Maps app. If the app supports pinning routes or destinations to Start, this is probably possible. If not, it may not be possible in the app. Most apps aren't designed to accept command-line parameters, so even if you make them the default handler for a given filetype or URI scheme, they ignore the value you send them and just start as though launched from Start.
GoodDayToDie said:
If the app supports pinning routes or destinations to Start, this is probably possible.
Click to expand...
Click to collapse
Nokia Drive supports pinning to start so it should be possible. Unfortunately I can't tell you exact command line parameters 'cause my Lumia 900 still "in jail"
Let me see if I have a copy of the Nokia Drive XAP handy. I'll need to decompile it to figure out the correct parameters for launching it with the intent of navigating to a specific location. Note also that this might not be possible directly - for example, the app might store a list of locations internally, and the tiles only provide an index into that list rather than providing the location directly - but that just requires another layer of indirection.
In that case, you create an app that gets registered as the navigation handler, and in response to a navigation request, it writes the requested location into the Nokia Drive app and then chain-launches Nokia Drive with the index of the newly written location. That's just an example of one way that this might go wrong, but overall, the odds are actually pretty good. Obviously, all of this will require, at a minimum, write access to the HKCR hive in the registry.
Ah, guys! You are so kind helping me out. I´m really certain alot of members in the WP7 section would love for this to work!
// Manneman
GoodDayToDie said:
I'll need to decompile it to figure out the correct parameters for launching it with the intent of navigating to a specific location
Click to expand...
Click to collapse
GoodDayToDie, you may try much simpler solution. Just create assembly (dll) to show startup parameters in message box, and replace main Nokia Drive dll (but pin some location first).
That's actually harder than it sounds; even if the app is sideloaded (which would mean I already have the DLL) my fake would have to mimic the internal structure of the real app to a degree (namespaces, class names, default actions, etc.). That's not hard, but decompiling .NET is pretty trivial too.
AFAIR, Nokia Drive is obfuscated (but I'm not 100% sure). Also, you don't need to duplicate all names and structures; just a stuff mentioned in WMAppManifest (I hope so). BTW, I forgot: I still have unlocked handset; if I'll found time, will try today later.
Update: tried but without of luck What I did:
- installed Nokia Drive first;
- downloaded map and pinned current location;
- created fake app with same app guid and namespace name ("Drive"), and performed app update (that operation completely override whole solution but NokiaDrive tile still pinned to the start screen);
- tried a few different page names (_default.xaml, QuickStartPage.xaml, DestinationPickerPage.xaml, FavoritesPage.xaml) with code
Code:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
MessageBox.Show("Hello from fake dll");
if (e.NavigationMode == System.Windows.Navigation.NavigationMode.New)
{
string[] keys = NavigationContext.QueryString.Keys.ToArray();
string[] values = NavigationContext.QueryString.Values.ToArray();
string param = "";
for (int i = 0; i < keys.Length; i++)
{
param += keys[i] + " -> " + values[i] + "\n";
}
MessageBox.Show("parameters: " + param);
}
}
But result always the same: app doesn't start from the pinned tile
Update 2: Finally, I did it
The trick is:
- do the same as I've described above (you should have pinned tile from ND);
- add following code to the start page:
Code:
public MainPage()
{
InitializeComponent();
var appTile = ShellTile.ActiveTiles.Last();
if (appTile != null)
{
//MessageBox.Show(appTile.NavigationUri.OriginalString);
EmailComposeTask emailTask = new EmailComposeTask();
emailTask.Subject = "NokiaDrive pinned parameters";
emailTask.Body = appTile.NavigationUri.OriginalString;
try
{
emailTask.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
}
}
}
- run app as usual (not from tile);
We allset - all params are sent to our email (I'm too lazy to manually copy all stuff )
Here we are (start parameters; bold values are changed for privacy reason ):
/_default?destination.name=200 SomeName Street&destination.latitude=49.5255378801376&destination.longitude=-72.4296837244183&destination.address.street=SomeName Street&destination.address.houseno=200&destination.address.district=&destination.address.county=&destination.address.city=SomeCity&destination.address.state=&destination.address.country=USA&destination.address.postcode=05720&destination.hashCode=371767793destination.address.statecode=MA&pinnedFrom=Favorites
P.S. Just found: Navigon also has ability to pin address to the start tile So, if you find the way to modify map protocol (or how it calls), it will be a really nice hack! BTW, could you remind me: do we have ability to launch assembly by GUID (on the full-/policy-unlocked phones)? If "yes", it's possible to write a real nice "proxy" app to handle map requests
I don't know about launching assemblies directly, but it's certainly possible to launch apps by GUID. It doesn't even require anything more than dev-unlock in fact (although of course you can only launch apps that you could launch anyhow). So yes, a proxy app is totally possible. That's actually what I'm working on (started as a project to make a Kindle ebook file loader, that would pur .mobi/.prc file in the Kindle app's folder and then launch the app).
GoodDayToDie, could you please, take a look to the registry, for default map protocol handler and figure out how to change that stuff? I'm pretty busy these days (and probably will be extremely busy couple of next months) but we can cooperate and create this app...
I'll investigate, but you're not the only one busy. If you've noticed a lack of software from me recently, it's due to the nex job I got some months back; I love it, but it leaves me with a lot less time for phone hacking if I want to still have a life outside of that.
With that said, this actually ties into the work I'm already doing with things like filetype handling and default browser switching. I can send you my HKCRlib, at a minimum; it's a library that simplifies interacting with HKCR, including creating backups of important values when they change, and reverting the backups.
GoodDayToDie, truly, I'm not much interested (personally) in that hack 'cause I can't use it for my Lumia 900. So it's only for the community needs but because of lack of time, I believe, we may put it on hold.

Categories

Resources