|
ChronometerDemo1.java
package com.example.testsensors;<br />
<br />
import android.app.Activity;<br />
import android.content.Context;<br />
import android.os.Bundle;<br />
import android.os.SystemClock;<br />
import android.util.Log;<br />
import android.view.Menu;<br />
import android.widget.Chronometer;<br />
import android.widget.Toast;<br />
<br />
public class ChronometerDemo1 extends Activity {<br />
private static final String TAG = "CustomChronometerActivity";<br />
private static final String MS_ELAPSED = "com.etc.etc.MsElapsed";<br />
<br />
private static MyChronometer chrono;<br />
<br />
<br />
@Override<br />
public void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
<br />
chrono = new MyChronometer(this);<br />
chrono.start();<br />
setContentView(chrono);<br />
}<br />
<br />
@Override<br />
protected void onPause() {<br />
Log.i(TAG, "onPause()");<br />
super.onPause();<br />
chrono.stop();<br />
}<br />
<br />
@Override<br />
protected void onResume() {<br />
Log.i(TAG, "onResume()");<br />
super.onResume();<br />
chrono.start();<br />
}<br />
<br />
@Override<br />
protected void onSaveInstanceState(Bundle outState) {<br />
super.onSaveInstanceState(outState);<br />
Log.i(TAG, "onSaveInstanceState()");<br />
chrono.stop();<br />
outState.putInt(MS_ELAPSED, chrono.getMsElapsed());<br />
}<br />
<br />
@Override<br />
protected void onRestoreInstanceState(Bundle savedInstanceState) {<br />
super.onRestoreInstanceState(savedInstanceState);<br />
Log.i(TAG, "onRestoreInstanceState()");<br />
int ms = savedInstanceState.getInt(MS_ELAPSED);<br />
chrono.setMsElapsed(ms);<br />
chrono.start();<br />
}<br />
<br />
class MyChronometer extends Chronometer {<br />
<br />
public int msElapsed;<br />
public boolean isRunning = false;<br />
<br />
public MyChronometer(Context context) {<br />
super(context);<br />
}<br />
<br />
public int getMsElapsed() {<br />
return msElapsed;<br />
}<br />
<br />
public void setMsElapsed(int ms) {<br />
setBase(getBase() - ms);<br />
msElapsed = ms;<br />
}<br />
<br />
@Override<br />
public void start() {<br />
super.start();<br />
setBase(SystemClock.elapsedRealtime() - msElapsed);<br />
isRunning = true;<br />
}<br />
<br />
@Override<br />
public void stop() {<br />
super.stop();<br />
if(isRunning) {<br />
msElapsed = (int)(SystemClock.elapsedRealtime() - this.getBase());<br />
}<br />
isRunning = false;<br />
}<br />
}<br />
<br />
public static void onCreate() {<br />
chrono.start(); <br />
}<br />
}
|
|
|
|
|
Do not post the same question in more than one forum. It annoys people, and they won't answer your question.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Hi All,
I am new to Andriod Development, and i am using Eclipse java IDE.
i am having troubles when i edit any files. The application is working fine unless each time if you need to change in any of the layout files or manifiest. (baiscally the XML files) it always troubling me
just generating a empty of the file name with an "out" extention. example main.out.xml.
then i have do delete the file and uload/load project manytimes and then it will come back to normal. this problem making me nurvois to change any files.
can anybody tell me what is exactly the cause of this problem?
thanks
Hussain Mohammed Saleh Attiya
ISP Technical Manager
Atyaf Telcom - Bahrain
|
|
|
|
|
Hi,
at last i found the solutions in one of the forums
ye but its still a bug. pretty amazing this survived beta.
forums i read said you need to:
1) delete the main.out.xml file
2) close all layout files
3) select a .java file or the project node and then try to run
nup. Still didn't work. I finally found out, purely by accident, that you also need to delet the compoile error that appears under the problems tab.
Hussain Mohammed Saleh Attiya
ISP Technical Manager
Atyaf Telcom - Bahrain
|
|
|
|
|
Hi everyone,
I not really good with programming, so I need some help. Does anybody know how to create a stopwatch for an Android phone using Java programming? Thanks in advance.
|
|
|
|
|
You could store the System.currentTimeMillis() in a long upon a start button press to note the start time. When someone presses stop read the System.currentTimeMillis() again and substract the already stored value from the start. Now you are left with the amount of milli seconds that passed between the two events.
|
|
|
|
|
Hi, thanks for your help. But I don't know where to start. So this is what I have found so far. Thanks in advance for the help.
package com.novoda.runbuddy.activity;<br />
<br />
public class StopWatch {<br />
<br />
private long startTime = 0;<br />
private long stopTime = 0;<br />
private long elapsed = 0;<br />
private boolean running = false;<br />
<br />
<br />
public void start() {<br />
this.startTime = System.nanoTime();<br />
this.running = true;<br />
}<br />
<br />
<br />
public void stop() {<br />
this.stopTime = System.nanoTime();<br />
this.running = false;<br />
}<br />
<br />
public void reset() {<br />
this.startTime = 0;<br />
this.stopTime = 0;<br />
this.running = false;<br />
}<br />
<br />
public long getElapsedTimeMicro() {<br />
if (running) {<br />
elapsed = ((System.nanoTime() - startTime) / 1000);<br />
}<br />
else {<br />
elapsed = ((stopTime - startTime) / 1000);<br />
}<br />
return elapsed;<br />
}<br />
<br />
public long getElapsedTimeMilli() {<br />
if (running) {<br />
elapsed = ((System.nanoTime() - startTime) / 1000000);<br />
}<br />
else {<br />
elapsed = ((stopTime - startTime) / 1000000);<br />
}<br />
return elapsed;<br />
}<br />
}
|
|
|
|
|
Hi,
I'm kinda new to programming and with not much knowledge on Java. But this is urgent!! I need help in research. I'm need to create a mobile application using Android and Eclipse.
Objectives:
To develop a mobile application that would be able to push help messages in the event whereby the mobile user requires assistance.
Scope of project:
Develop a mobile application that;
A module to detect movements
A decision making module with the intelligence to trigger an alert based on a set of rules
A module to push an alert message to a 3rd party e.g. via the SMS
Any ideas on how I should go about doing this? Thanks.
Best Regards,
|
|
|
|
|
-- Download SDK[SDK ^] for Android.
-- Download the development tools - can get from the previous link
-- Read the development articles.
-- Start your Hello World application.
-- Think & plan for your project
"He that is good with a hammer tends to think everything is a nail." - Abraham Maslow
|
|
|
|
|
I want to create Menu,Menu item , POP up menu and table like gui using MIDP 2.0 . How it is possible
Trioum
|
|
|
|
|
hi there,
Im really confused! i need to connect sql server from my pocket pc ...
i made a wireless network and connect them to each other.
now with this code i try to connect ...
SqlConnection con = new SqlConnection(@"Data Source=mohsen-pc\sqlexpress;Initial Catalog=ManagerCo;Persist Security Info=True;User ID=sa;Password=123456");
SqlCommand cmd = con.CreateCommand();
try
{
con.Open();
}
catch (Exception f)
{
MessageBox.Show(f.Message);
}
sqlexception is result!
note that firewall is switched off, sql express accepts remote and configured correctly
plz help!!!!!!!!!1
|
|
|
|
|
Would you post the exception details? That will help to determine the issue.
|
|
|
|
|
please clear your question to justify it
what is error in this code and what about exception. Mention it
then we can solved it.
|
|
|
|
|
I make program for recording phone conversation to a file.I need help. I can not find a way to start recording after receiving a call? Is there a function in the Windows Mobile API for this/
|
|
|
|
|
How to handle key events in Pocket Internet Explorer using javascript?
|
|
|
|
|
What are my options for creating websites for mobile?
What is WAP? Or use ASP.net to sniff which browser the request came from?
|
|
|
|
|
Hello
Use standard ASP.NET website project for creating mobile website. Important thing here is to detect request, if it is from mobile device than redirect user to mobile compatible pages instead of standard website.
For accurate and easy mobile device detection use http://51degrees.codeplex.com[^] It is an ASP.NET open source module which detects mobile devices and provides auto redirection to mobile optimized pages when request is coming from mobile device. It makes use of WURFL mobile device database.
Sample web.config configuration for redirecting users to different mobile pages based on MobileDeviceManufacturer property. You can create your own custom rules for redirection based on other mobile properties.
<redirect firstRequestOnly="false"
mobileHomePageUrl="~/Mobile/Default.aspx"
timeout="20"
devicesFile="~/App_Data/Devices.dat"
mobilePagesRegex="/(Apple|RIM|Nokia|Mobile)/">
<locations>
<location url="~/Apple/Default.aspx">
<add property="MobileDeviceManufacturer" matchExpression="Apple"/>
</location>
<location url="~/RIM/Default.aspx">
<add property="MobileDeviceManufacturer" matchExpression="RIM"/>
</location>
<location url="~/Nokia/Default.aspx">
<add property="MobileDeviceManufacturer" matchExpression="Nokia"/>
</location>
</locations>
</redirect>
|
|
|
|
|
I am new for iphone technology as i was vc++ developer. I am working on record audio and got one source code "SpeakHere" that fulfill my requirement but it is to lengthy. lots of files are used there ... if someone guide me on how to record audio in minimum number of lines.
Any doc or source code ??
Thanks in advance
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
|
Is this a programming question?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
This is a discussion board for Mobile Programming questions. Unless you want to develope mobile applications for iPhone and wondering if you should go ahead and develope one for this chinese phone; you are in the wrong place.
|
|
|
|
|
I've wanted to get into development for smart phones, but the phones/plans are all so insanely expensive (at least in the US), I can't even come close to affording one right now. Not to mention multi-platform development.
I was wondering, is a phone absolutely necessary? How accurate are the emulators compared to the real thing? Is it possible to make apps without ever testing them on an actual device? I'm mainly interested in the Android and WP7 emulators.
Any info/advice would be greatly appreciated.
Thanks...
We live in a world operated by science and technology. We have also arranged things so that almost no one understands science and technology. This is a prescription for disaster. We might get away with it for a while, but sooner or later this combustible mixture of ignorance and power is going to blow up in our faces.
--Carl Sagan
|
|
|
|
|
I haven't done any Android dev (yet) or WP7 (probably never), but I have used at least 5 of the J2ME emulators from various manufacturers. My experience with them is that they each have a different set of bugs from the real phones. In that world, you can go a fair way on one or more emulators, but your final tweaking will almost certainly need a real phone.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
I have an android phone, (droid2 running on froyo) and i also use the emulator. in my experience, the emulator is harder to work with simply because it takes up 90% of your system resources no matter how amazing your computer is. but as far as i have seen, as long as you don't want to use the sensors(orientation/compass, or accelerometer)much, it works about the same...
|
|
|
|
|
The WP7 emulator is actually quite good. Service calls, Push Notifications, local storage, 3D graphics, etc all work well.
There are some obvious things you can't do, like get GPS data, but in general there isn't much you can't do in the emulator.
Performance testing should certainly be done on actual hardware of course.
|
|
|
|