[android-developers] How do I enable the phone's key guard programmatically?

2010-05-11 Thread Walles
Hi!

How do I enable the phone's key guard programmatically?

The use case is that I want to make an app that enables the key guard
when I use my Bluetooth headset to answer a call.

Currently with my HTC Hero there's no way for me to physically enable
the key guard during a call since the phone's lock button doubles as a
hang-up button during calls.  And if I answer a call with my phone in
my pocket the phone tends to hang up on me after a while...

PowerManager.goToSleep() looks promising, but apparently I'm not
allowed to call that without the DEVICE_POWER permission which I can't
have.  And even if I could call it, would it do the right thing during
a call?

KeyLockManager only seems useful for people who want to *prevent* the
lock screen from appearing, but I want to trigger it.

Help!

  //Johan

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android 2.0 source group

2009-12-01 Thread Walles
This might be a bit crude, but what I usually do is this:

1. Search Google for:
mediarecorder.java site:.kernel.org

2. Click on the first hit.

3. Find MediaRecorder.java on that page and click on the "blob" link
next to it.

4. Click on HEAD.

I've always found the source code I wanted this way.  YMMV.

  Cheers //Johan

On 30 Nov, 17:49, me  wrote:
>     Would someone be kind enough to zipup the android 2.0 source code
> related to the MediaRecorder class and email it to me?  My code works
> fine in the emulator but MediaRecorder.Start() is failing on the
> droid.  There error message only says could not start.
>
> Thanks
> michaelto...@yahoo.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Where do I write my changelog?

2009-11-07 Thread Walles
To answer my own question in case somebody else wants to know, what
people do is simply to change the description of the app after every
release, so that it includes a description of the latest change.

On 23 Sep, 12:00, Walles  wrote:
> Hi!
>
> When upgrading apps I've downloaded from Market, I'm sometimes
> presented with a list of changes since the last version.
>
> When I publish my own apps, where am I supposed to list my changes for
> the Market app to show them to potential upgraders?
>
>   Regards //Johan

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: What does the Location accuracy mean?

2009-11-06 Thread Walles
The wiki page says it's a radius if I interpret it correctly:

"
In order to apply the CEP concept in these conditions, we can define
CEP as the [...] radius of a circle within which 50% of rounds will
land.
"

Or am I skipping too much text in between there? :-) //Johan

On 6 Nov, 07:07, "Maps.Huge.Info (Maps API Guru)" 
wrote:
> I believe it's CEP or Circular Error Probability:
>
> http://en.wikipedia.org/wiki/Circular_error_probable
>
> Another words, your point can be anywhere inside the circle of X
> meters diameter.
>
> -John Coryat
>
> "Radar Now!"
>
> "What Zip Code?"

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] What does the Location accuracy mean?

2009-11-05 Thread Walles
If I do Location.getAccuracy() I get a number of meters.

Is that number a radius or a diameter?

I thought it would be a radius, but Google's MyLocationOverlay uses
that value as a diameter.

  Regards //Johan

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: INSTALL_FAILED_MISSING_SHARED_LIBRARY

2009-11-02 Thread Walles
The device you're running on must have the Google API things
installed, make sure the AVD description says something about Google.

AVD setup is described here: 
http://developer.android.com/guide/developing/tools/avd.html

Try reading the blue box at the top of
http://developer.android.com/guide/tutorials/views/hello-mapview.html
carefully and following its instructions to the letter.

  Regards //Johan

On 2 Nov, 10:44, "Sasikumar.S"  wrote:
> Hi,
>
> Any one know about INSTALL_FAILED_MISSING_SHARED_LIBRARY Error.
>
> I tried to execute Google Map appluication in android.
> In that time it is showed INSTALL_FAILED_MISSING_SHARED_LIBRARY exception.
>
> If any one know about these.
> Pls reply to me...
>
> --
> Thanks & Regards
> Sasikumar.S

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How to style a Button to look like a Spinner?

2009-10-26 Thread Walles

Hi!

I want to create a Button that looks like a Spinner.
Programmatically, this works fine:

Button button = new Button(this, null,
android.R.attr.spinnerStyle);

How can I do the same thing in my layout XML files?

  Regards //Johan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] How to connect a context menu to a spinner popup?

2009-10-12 Thread Walles

Hi!

I have a spinner that I've read from an XML file.  When I click the
spinner, it pops up a list of stuff.  I'd like to connect a context
menu to the popped up list.  How can I do that?

I have attempted registerForContextMenu(Spinner), but that adds the
context menu to the spinner itself rather than the list it pops up.

  Help! //Johan

Spinner setup code:
http://bazaar.launchpad.net/~walles/sl/trunk/annotate/49/StockholmPublicTransport/src/com/johan/sl/SL.java#L140

Spinner XML (it's the fromSpinner and the toSpinner that I want to
provide with context menus):
http://bazaar.launchpad.net/~walles/sl/trunk/annotate/49/StockholmPublicTransport/src/com/johan/sl/SL.java#L140
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Geocoder.getFromLocationName() has bad javadocs

2009-10-11 Thread Walles

There is a Geocoder.getFromLocationName(name, max, lat, lon, lat, lon)
method.

The documentation says it should search inside the (lat, lon, lat,
lon) bounding box:
http://developer.android.com/reference/android/location/Geocoder.html#getFromLocationName(java.lang.String,
int, double, double, double, double)

In reality I get lots of hits outside of that box and none inside it
when I use that method.

Is there some other method I can use if I want to search for a user-
provided location string inside a bounding box?

  Regards //Johan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Geocoder.getFromLocationName() ignores bounding box

2009-10-08 Thread Walles

findMe should be "Storgatan 5", sorry about that:

 Locale swedish = new Locale("sv");
 Geocoder geocoder = new Geocoder(this, swedish);
 locations = geocoder.getFromLocationName("Storgatan 5", 700);

No hit in Stockholm though :-(, this one expected:
http://maps.google.com/maps?f=q&source=s_q&hl=sv&geocode=&q=storgatan+5&sll=59.333857,18.087831&sspn=0.004367,0.00825&ie=UTF8&hq=&hnear=Storgatan+5,+11444,+Sverige&ll=59.33569,18.080717&spn=0.004366,0.00825&z=17

  //Johan

On 8 Okt, 19:32, Walles  wrote:
> Actually, it doesn't work even with the simple form:
>
>     Locale swedish = new Locale("sv");
>     Geocoder geocoder = new Geocoder(this, swedish);
>     locations = geocoder.getFromLocationName(findMe, 700);
>
> I get 20 hits from that, none of them in Stockholm (which is the one
> I'm looking for).
>
> Help!
>
>   //Johan
>
> On 8 Okt, 10:36, Nithin  wrote:
>
> > hi Walles,
>
> > geocoder.getFromLocationName(locationName, 5); will return a list of
> > values and here, 5 is the no. of results(values) we want. So according
> > to that we can get the corresponding latitude and longitude..
>
> > Thanks
> > Nithin
>
> > here, 5 is the total number of results, that we want,
>
> > On Oct 8, 11:14 am, Walles  wrote:
>
> > > How can I convert a street address into a latitude + longitude?
>
> > > I've tried to use Geocoder.getFromLocationName() with a bounding box,
> > > but all results I get are outside of the box.  Is there a way to limit
> > > the hits to a certain area on earth?
>
> > >    Regards //Johan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Geocoder.getFromLocationName() ignores bounding box

2009-10-08 Thread Walles

Actually, it doesn't work even with the simple form:

Locale swedish = new Locale("sv");
Geocoder geocoder = new Geocoder(this, swedish);
locations = geocoder.getFromLocationName(findMe, 700);

I get 20 hits from that, none of them in Stockholm (which is the one
I'm looking for).

Help!

  //Johan

On 8 Okt, 10:36, Nithin  wrote:
> hi Walles,
>
> geocoder.getFromLocationName(locationName, 5); will return a list of
> values and here, 5 is the no. of results(values) we want. So according
> to that we can get the corresponding latitude and longitude..
>
> Thanks
> Nithin
>
> here, 5 is the total number of results, that we want,
>
> On Oct 8, 11:14 am, Walles  wrote:
>
> > How can I convert a street address into a latitude + longitude?
>
> > I've tried to use Geocoder.getFromLocationName() with a bounding box,
> > but all results I get are outside of the box.  Is there a way to limit
> > the hits to a certain area on earth?
>
> >    Regards //Johan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Geocoder.getFromLocationName() ignores bounding box

2009-10-08 Thread Walles

Hi Nithin!

Why doesn't the below code work?  It gets me 11 hits, all outside of
the box.  The one I'm really looking for is this:

http://maps.google.com/maps?f=q&source=s_q&hl=sv&geocode=&q=storgatan+5&sll=59.333857,18.087831&sspn=0.004367,0.00825&ie=UTF8&hq=&hnear=Storgatan+5,+11444,+Sverige&ll=59.33569,18.080717&spn=0.004366,0.00825&z=17

final double SL_LOWER_LEFT_LAT = 58.9693;
final double SL_LOWER_LEFT_LON = 17.1754;
final double SL_UPPER_RIGHT_LAT = 59.8307;
final double SL_UPPER_RIGHT_LON = 19.1907;

Locale swedish = new Locale("sv");
Geocoder geocoder = new Geocoder(this, swedish);
locations =
geocoder.getFromLocationName("Storgatan 5", 7,
 SL_LOWER_LEFT_LAT,
SL_LOWER_LEFT_LON,
 SL_UPPER_RIGHT_LAT,
SL_UPPER_RIGHT_LON);

  Regards //Johan

On 8 Okt, 10:36, Nithin  wrote:
> hi Walles,
>
> geocoder.getFromLocationName(locationName, 5); will return a list of
> values and here, 5 is the no. of results(values) we want. So according
> to that we can get the corresponding latitude and longitude..
>
> Thanks
> Nithin
>
> here, 5 is the total number of results, that we want,
>
> On Oct 8, 11:14 am, Walles  wrote:
>
> > How can I convert a street address into a latitude + longitude?
>
> > I've tried to use Geocoder.getFromLocationName() with a bounding box,
> > but all results I get are outside of the box.  Is there a way to limit
> > the hits to a certain area on earth?
>
> >    Regards //Johan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Geocoder.getFromLocationName() ignores bounding box

2009-10-07 Thread Walles

How can I convert a street address into a latitude + longitude?

I've tried to use Geocoder.getFromLocationName() with a bounding box,
but all results I get are outside of the box.  Is there a way to limit
the hits to a certain area on earth?

   Regards //Johan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Geocoder.getFromLocationName() vs bounding box?

2009-10-04 Thread Walles

Hi!

I'm trying to use Geocoder.getFromLocationName() with a bounding box,
but:
* On 1.5 I get lots of results outside of my box.
* On 1.6 I get no results at all.

How should I use Geocoder.getFromLocationName() with a bounding box so
that I get results inside of the box but not outside of it?

Here's what I'm trying to do.  The example address "Storgatan 5" is
very common in Sweden and exists in lots of cities, so it's a good
test case.  The bounding box covers the Stockholm area:

/**
 * Try to find Storgatan 5 in Stockholm using {...@link
Geocoder#getFromLocationName(String, int, double, double, double,
double)}.
 * 
 * On 1.5, this example finds tons of "Storgatan 5"s, none of them
inside the
 * box unfortunately.
 * 
 * On 1.6 I get no results at all from this code.
 *
 * @author johan.wal...@gmail.com
 */
public class FindStorgatan extends Activity {
/**
 * Use this tag for logging.
 */
public final static String TAG = "Storgatan";

/**
 * Lower left latitude of SL's coverage.
 */
private static final double SL_LOWER_LEFT_LAT = 58.9693;

/**
 * Lower left longitude of SL's coverage.
 */
private static final double SL_LOWER_LEFT_LON = 17.1754;

/**
 * Upper right latitude of SL's coverage.
 */
private static final double SL_UPPER_RIGHT_LAT = 59.8307;

/**
 * Upper right longitude of SL's coverage.
 */
private static final double SL_UPPER_RIGHT_LON = 19.1907;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Set up our Geocoder
Locale swedish = new Locale("sv");
Geocoder geocoder = new Geocoder(this, swedish);

// "Storgatan 5" is a common address in many Swedish cities
String findMe = "Storgatan 5";

List locations;
try {
locations =
geocoder.getFromLocationName(findMe, 7,
 SL_LOWER_LEFT_LAT,
 SL_LOWER_LEFT_LON,
 SL_UPPER_RIGHT_LAT,
 SL_UPPER_RIGHT_LON);
} catch (IOException e) {
Log.e(TAG, "Address decoding failed for: " + findMe, e);
return;
}

StringBuilder result = new StringBuilder();
result.append(locations.size());
result.append(" results found for ");
result.append(findMe);
result.append(":\n");
for (Address address : locations) {
String addressLine = address.getAddressLine(0);
String city = address.getAddressLine(1);
String lat = Double.toString(address.getLatitude());
String lon = Double.toString(address.getLongitude());
String coordinate = lat + ", " + lon;

if (!findMe.equals(addressLine)) {
result.append(addressLine).append(", ");
}
result.append(city).append(": ").append(coordinate).append
('\n');
}

// Display our result
TextView textView = new TextView(this);
textView.setText(result);
setContentView(textView);
}
}

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: WebView onLoadComplete()?

2009-09-28 Thread Walles

Thanks Mark, that was exactly what I needed.  You rule.

  Cheers :-) //Johan

On 27 Sep, 17:23, Mark Murphy  wrote:
> Walles wrote:
> > I have aWebViewthat I've asked to load a page usingwebView.loadUrl
> > ().
>
> > How do I get a notification when theWebViewhas completed loading +
> > rendering the requested page?
>
> Step #1: Implement a custom subclass of WebViewClient, overriding
> onPageFinished() and putting in there your logic to be invoked when the
> page is ready:
>
> http://developer.android.com/reference/android/webkit/WebViewClient.h...)
>
> Step #2: Attach an instance of that WebViewClient subclass to theWebViewvia 
> setWebViewClient():
>
> http://developer.android.com/reference/android/webkit/WebView.html#se...)
>
> Step #3: There is no Step #3
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> _Beginning Android_ from Apress Now Available!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] WebView onLoadComplete()?

2009-09-27 Thread Walles

I have a WebView that I've asked to load a page using webView.loadUrl
().

How do I get a notification when the WebView has completed loading +
rendering the requested page?

The closest I've gotten is webView.getProgress(), but I'd like to be
notified rather than having to poll for that value to reach 100.

  Regards //Johan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Where do I write my changelog?

2009-09-23 Thread Walles

Hi!

When upgrading apps I've downloaded from Market, I'm sometimes
presented with a list of changes since the last version.

When I publish my own apps, where am I supposed to list my changes for
the Market app to show them to potential upgraders?

  Regards //Johan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Location constructors are stubs?

2009-09-22 Thread Walles

Seems like the contents of that jar file only has dummy
implementations of all methods.  Found this thread explaining it a
bit:
http://groups.google.com/group/android-developers/browse_thread/thread/a680b65f287e1b8c

Solution is to run all tests on the simulator (or the real device).
Visually it still looks the same in Eclipse, thank you Eclipse ADT
plugin developers :-).

  //Johan

On 21 Sep, 08:27, Walles  wrote:
> Hi!
>
> I'm writing unit tests for a class containing Locations.  To create a
> (mock) Location, I do this:
>
> Location from = new Location("Johan");
>
> However, the Location(String) constructor throws a RuntimeException
> saying "Stub!".
>
> How can I create a mock location?
>
> Note that I'm running this on the plain JDK with android.jar in the
> path, after JUnit but before my own stuff.  No device or emulator is
> involved.  The android.jar file is from the platforms/android-1.5
> directory of android-sdk-linux_x86-1.6_r1.
>
>   Regards //Johan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Location constructors are stubs?

2009-09-20 Thread Walles

Hi!

I'm writing unit tests for a class containing Locations.  To create a
(mock) Location, I do this:

Location from = new Location("Johan");

However, the Location(String) constructor throws a RuntimeException
saying "Stub!".

How can I create a mock location?

Note that I'm running this on the plain JDK with android.jar in the
path, after JUnit but before my own stuff.  No device or emulator is
involved.  The android.jar file is from the platforms/android-1.5
directory of android-sdk-linux_x86-1.6_r1.

  Regards //Johan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How do I know whether my device is currently charging?

2009-09-20 Thread Walles

Is this documented anywhere?  I looked here...
http://developer.android.com/reference/android/os/BatteryManager.html

... but AFAICS there's nothing about 0 meaning "unplugged".

What you're suggesting *is* what I'm after, but I'm unwilling to use
undocumented API features since they risk disappearing without notice.

  Regards //Johan

On 19 Sep, 22:29, Dianne Hackborn  wrote:
> What do you mean by "in use"?  You can find out whether you are attached to
> a power source with the "plugged" field (0 means not plugged in / on
> battery, non-zero is the power source), which is generally what things use
> to determine whether the device is plugged in (so it is okay to do more
> power drawing operations).
>
>
>
> On Sat, Sep 19, 2009 at 12:42 PM, Walles  wrote:
>
> > Thanks Mark, that was the hint I needed.
>
> > What I really wanted to know was whether or not the battery was
> > currently in use, and for anybody else following this thread, here's
> > the method I came up with:
>
> > "
> >    /**
> >     * Is the battery currently discharging?
> >     *
> >     * @return True if our battery is discharging.  False otherwise.
> >     */
> >    private boolean isDischarging() {
> >        // Contact the battery manager
> >        Intent batteryIntent =
> >            registerReceiver(null, new IntentFilter
> > (Intent.ACTION_BATTERY_CHANGED));
> >        if (batteryIntent == null) {
> >            Log.w(DrainOMeter.LOGGING_TAG,
> >                  "Failed to talk to the battery manager, assuming
> > we're on battery power");
> >            return true;
> >        }
>
> >        // Ask about battery charging status
> >        int batteryStatus = BatteryManager.BATTERY_STATUS_UNKNOWN;
> >        if (batteryIntent != null) {
> >            batteryStatus =
> >                batteryIntent.getIntExtra("status",
>
> > BatteryManager.BATTERY_STATUS_UNKNOWN);
> >        }
> >        if (batteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN) {
> >            Log.w(DrainOMeter.LOGGING_TAG,
> >                  "Failed to get battery charging status, assuming
> > we're on battery power");
> >            return true;
> >        }
>
> >        return batteryStatus ==
> > BatteryManager.BATTERY_STATUS_DISCHARGING;
> >    }
> > "
>
> >  Cheers //Johan
>
> > On 18 Sep, 11:54, Mark Murphy  wrote:
> > > Walles wrote:
> > > > I want to know if my device is currently charging.
>
> > > > How do I find that out?  I've been looking a bit at the Intents API,
> > > > but AFAIU I can just subscribe to events from there, and a
> > > > subscription is not what I'm after.  And even if I *did* want updates,
> > > > I'd still need to know the initial state.
>
> > > > I just want to ask a one-shot "are we charging" question.  How can I
> > > > do that?
>
> > > Register for the broadcast Intent with a null receiver. If you get a
> > > non-null return value, then that return value is an Intent from the last
> > > "sticky broadcast" matching your supplied IntentFilter. I believe the
> > > battery updates are such a sticky broadcast. By passing null for the
> > > receiver, you do not actually register a receiver and so do not need to
> > > unregister anything later.
>
> > > For more instructions on this, look up registerReceiver() in the Context
> > > class (which is a base class for Activity, Service, etc.).
>
> > > --
> > > Mark Murphy (a Commons Guy)http://commonsware.com|
> >http://twitter.com/commonsguy
>
> > > _The Busy Coder's Guide to *Advanced* Android Development_
> > > Version 1.1 Available!
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How do I know whether my device is currently charging?

2009-09-19 Thread Walles

Thanks Mark, that was the hint I needed.

What I really wanted to know was whether or not the battery was
currently in use, and for anybody else following this thread, here's
the method I came up with:

"
/**
 * Is the battery currently discharging?
 *
 * @return True if our battery is discharging.  False otherwise.
 */
private boolean isDischarging() {
// Contact the battery manager
Intent batteryIntent =
registerReceiver(null, new IntentFilter
(Intent.ACTION_BATTERY_CHANGED));
if (batteryIntent == null) {
Log.w(DrainOMeter.LOGGING_TAG,
  "Failed to talk to the battery manager, assuming
we're on battery power");
return true;
}

// Ask about battery charging status
int batteryStatus = BatteryManager.BATTERY_STATUS_UNKNOWN;
if (batteryIntent != null) {
batteryStatus =
batteryIntent.getIntExtra("status",
 
BatteryManager.BATTERY_STATUS_UNKNOWN);
}
if (batteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN) {
Log.w(DrainOMeter.LOGGING_TAG,
  "Failed to get battery charging status, assuming
we're on battery power");
return true;
}

return batteryStatus ==
BatteryManager.BATTERY_STATUS_DISCHARGING;
}
"

  Cheers //Johan

On 18 Sep, 11:54, Mark Murphy  wrote:
> Walles wrote:
> > I want to know if my device is currently charging.
>
> > How do I find that out?  I've been looking a bit at the Intents API,
> > but AFAIU I can just subscribe to events from there, and a
> > subscription is not what I'm after.  And even if I *did* want updates,
> > I'd still need to know the initial state.
>
> > I just want to ask a one-shot "are we charging" question.  How can I
> > do that?
>
> Register for the broadcast Intent with a null receiver. If you get a
> non-null return value, then that return value is an Intent from the last
> "sticky broadcast" matching your supplied IntentFilter. I believe the
> battery updates are such a sticky broadcast. By passing null for the
> receiver, you do not actually register a receiver and so do not need to
> unregister anything later.
>
> For more instructions on this, look up registerReceiver() in the Context
> class (which is a base class for Activity, Service, etc.).
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to *Advanced* Android Development_
> Version 1.1 Available!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] How do I know whether my device is currently charging?

2009-09-17 Thread Walles

I want to know if my device is currently charging.

How do I find that out?  I've been looking a bit at the Intents API,
but AFAIU I can just subscribe to events from there, and a
subscription is not what I'm after.  And even if I *did* want updates,
I'd still need to know the initial state.

I just want to ask a one-shot "are we charging" question.  How can I
do that?

  Regards //Johan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Probing for an already set Alarm?

2009-09-17 Thread Walles

I'm not a big fan of doing double bookkeeping like this, but it should
be doable here if I have a Preference stored with the time at which I
expect the next alarm to trigger.  Then I could just unconditionally
re-trigger that alarm both from the UI and from the sampler.

That said, I still feel that I'm trying to duplicate the
AlarmManager's bookkeeping here, and just being able to ask it about
its state would feel cleaner.

Thanks for all your feedback!

  Regards //Johan

On 16 Sep, 18:33, Dianne Hackborn  wrote:
> You have to be receiving BOOT_COMPLETED to get your initial alarm.  When you
> get BOOT_COMPLETED, you know that you are at the initial boot of the system.
>  You can set up for whatever initial behavior you want at that point.
> Also, you could simply have some persistent data about the alarms you have
> scheduled and look at that.  You are the ONLY one scheduling your own
> alarms.  Nobody is changing them behind your back.  You know exactly what
> you are doing.   So just write it to do exactly what you want.
>
>
>
> On Wed, Sep 16, 2009 at 4:43 AM, Walles  wrote:
>
> > Let's say I change my code to:
>
> > Pseudo code for the UI:
> > 1. Set an updating alarm in 15s, request INITIAL.
> > 2. Show UI based on existing data.
>
> > Pseudo code for the sampler:
> > 0. If INITIAL, and we have samples in the database, return without
> > doing anything.
> > 1. Take a sample and store it in a database.
> > 2. Schedule a new alarm in 10 minutes, request KEEP_GOING.
>
> > Was that what you had in mind?
>
> > Then let's assume i re-start my phone, and launch the UI:
> > 1. UI sets an alarm requesting INITIAL.
> > 2. The sampler receives the alarm, sees that there are already samples
> > in the database, and never initiates the sample-and-set-up-another-
> > alarm chain.
>
> > So in the above case I still don't see how I can get around not being
> > able to check for pending alarms :-(.
>
> >  Regards //Johan
>
> > On 16 Sep, 08:14, Beth  wrote:
> > > All you need to do is to set different request codes in your pending
> > > intent parameters to avoid this situation:
> > > "The setting of this new alarm, and the throwing out of the existing
> > > alarm is what I want to avoid."
>
> > > A correction to one line of code would let you use the alarm manager
> > > (sorry if my earlier post was unclear).  You might further improve by
> > > using a Handler, thread or Async Task to collect your second sample
> > > after a 15s sleep and then trigger a repeating alarm every ten minutes
> > > thereafter.  To be clear, a phone reboot will cancel the repeating
> > > alarm but you can catch the event and restart.
>
> > > Good luck!
>
> > > On Sep 15, 10:31 pm, Walles  wrote:
>
> > > > The race is on then, we'll see who's the first to market!  Cheers :-) /
> > > > J
>
> > > > On 16 Sep, 06:44, Dianne Hackborn  wrote:
>
> > > > > Um, 1.6 will do this, and is probably what I would say is the "right"
> > way in
> > > > > that the implementation is very closely integrated into the system to
> > > > > monitor CPU usage, network usage, wakelock usage, screen usage, etc,
> > etc.
>
> > > > > On Tue, Sep 15, 2009 at 5:02 AM, Walles 
> > wrote:
>
> > > > > > Good point :-), here's the plan:
>
> > > > > > I'm writing an app to find out what apps are using the most CPU
> > time
> > > > > > (which I hope will correlate with battery drain).  It's possible to
> > > > > > get a snapshot picture of this by looking at /proc:
>
> >http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/annotate/head...<
> >http://bazaar.launchpad.net/%7Ewalles/drain-o-meter/trunk/annotate/he...>
>
> > > > > > A single snapshot picture will however miss apps that start, run
> > for
> > > > > > some time and then exit.
>
> > > > > > So what I want to do is to take *regular* snapshots.  I take the
> > > > > > difference between the last two snapshots and add the difference to
> > a
> > > > > > process name -> number of ticks Map.
>
> > > > > > Snapshotting rules are:
> > > > > > * Snapshots should be taken at regular intervals.
> > > > > > * The first two snapshots should be taken in quick succession to be
> > > > > > able to quickly present the first measurement to the user.
> > 

[android-developers] Re: Probing for an already set Alarm?

2009-09-16 Thread Walles

Let's say I change my code to:

Pseudo code for the UI:
1. Set an updating alarm in 15s, request INITIAL.
2. Show UI based on existing data.

Pseudo code for the sampler:
0. If INITIAL, and we have samples in the database, return without
doing anything.
1. Take a sample and store it in a database.
2. Schedule a new alarm in 10 minutes, request KEEP_GOING.

Was that what you had in mind?

Then let's assume i re-start my phone, and launch the UI:
1. UI sets an alarm requesting INITIAL.
2. The sampler receives the alarm, sees that there are already samples
in the database, and never initiates the sample-and-set-up-another-
alarm chain.

So in the above case I still don't see how I can get around not being
able to check for pending alarms :-(.

  Regards //Johan

On 16 Sep, 08:14, Beth  wrote:
> All you need to do is to set different request codes in your pending
> intent parameters to avoid this situation:
> "The setting of this new alarm, and the throwing out of the existing
> alarm is what I want to avoid."
>
> A correction to one line of code would let you use the alarm manager
> (sorry if my earlier post was unclear).  You might further improve by
> using a Handler, thread or Async Task to collect your second sample
> after a 15s sleep and then trigger a repeating alarm every ten minutes
> thereafter.  To be clear, a phone reboot will cancel the repeating
> alarm but you can catch the event and restart.
>
> Good luck!
>
> On Sep 15, 10:31 pm, Walles  wrote:
>
> > The race is on then, we'll see who's the first to market!  Cheers :-) /
> > J
>
> > On 16 Sep, 06:44, Dianne Hackborn  wrote:
>
> > > Um, 1.6 will do this, and is probably what I would say is the "right" way 
> > > in
> > > that the implementation is very closely integrated into the system to
> > > monitor CPU usage, network usage, wakelock usage, screen usage, etc, etc.
>
> > > On Tue, Sep 15, 2009 at 5:02 AM, Walles  wrote:
>
> > > > Good point :-), here's the plan:
>
> > > > I'm writing an app to find out what apps are using the most CPU time
> > > > (which I hope will correlate with battery drain).  It's possible to
> > > > get a snapshot picture of this by looking at /proc:
>
> > > >http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/annotate/head...<http://bazaar.launchpad.net/%7Ewalles/drain-o-meter/trunk/annotate/he...>
>
> > > > A single snapshot picture will however miss apps that start, run for
> > > > some time and then exit.
>
> > > > So what I want to do is to take *regular* snapshots.  I take the
> > > > difference between the last two snapshots and add the difference to a
> > > > process name -> number of ticks Map.
>
> > > > Snapshotting rules are:
> > > > * Snapshots should be taken at regular intervals.
> > > > * The first two snapshots should be taken in quick succession to be
> > > > able to quickly present the first measurement to the user.
> > > > * It must be possible for an UI app to look at the result of the
> > > > snapshotting.
>
> > > > To get the whole thing going, I'm letting the UI part of the
> > > > application start the sampler in the background.  When the sampling is
> > > > first started it needs to take two snapshots quickly (see above).  The
> > > > rest of the samples should be taken at longer intervals.
>
> > > > I first tried to do this using alarms, but I didn't manage to get the
> > > > "two quick samples first and the rest further apart" behavior with
> > > > alarms:
> > > >http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/files/39<http://bazaar.launchpad.net/%7Ewalles/drain-o-meter/trunk/files/39>
>
> > > > I now have a working implementation with a background service:
> > > >http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/files/57<http://bazaar.launchpad.net/%7Ewalles/drain-o-meter/trunk/files/57>
>
> > > > Suggestions on how I should *really* be doing welcome :-).
>
> > > >  Cheers //Johan
>
> > > > On 9 Sep, 16:47, Mark Murphy  wrote:
> > > > > Walleswrote:
> > > > > > I'll use a Service instead of an Alarm and keep it running in the
> > > > > > background.  That way I can keep track of it myself.
>
> > > > > Please don't. For starters, it won't work, since the service may get
> > > > > killed off by the user or the system. Also, while the service is in
> > > > > memory, 

[android-developers] Re: Probing for an already set Alarm?

2009-09-15 Thread Walles

The race is on then, we'll see who's the first to market!  Cheers :-) /
J

On 16 Sep, 06:44, Dianne Hackborn  wrote:
> Um, 1.6 will do this, and is probably what I would say is the "right" way in
> that the implementation is very closely integrated into the system to
> monitor CPU usage, network usage, wakelock usage, screen usage, etc, etc.
>
>
>
> On Tue, Sep 15, 2009 at 5:02 AM, Walles  wrote:
>
> > Good point :-), here's the plan:
>
> > I'm writing an app to find out what apps are using the most CPU time
> > (which I hope will correlate with battery drain).  It's possible to
> > get a snapshot picture of this by looking at /proc:
>
> >http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/annotate/head...<http://bazaar.launchpad.net/%7Ewalles/drain-o-meter/trunk/annotate/he...>
>
> > A single snapshot picture will however miss apps that start, run for
> > some time and then exit.
>
> > So what I want to do is to take *regular* snapshots.  I take the
> > difference between the last two snapshots and add the difference to a
> > process name -> number of ticks Map.
>
> > Snapshotting rules are:
> > * Snapshots should be taken at regular intervals.
> > * The first two snapshots should be taken in quick succession to be
> > able to quickly present the first measurement to the user.
> > * It must be possible for an UI app to look at the result of the
> > snapshotting.
>
> > To get the whole thing going, I'm letting the UI part of the
> > application start the sampler in the background.  When the sampling is
> > first started it needs to take two snapshots quickly (see above).  The
> > rest of the samples should be taken at longer intervals.
>
> > I first tried to do this using alarms, but I didn't manage to get the
> > "two quick samples first and the rest further apart" behavior with
> > alarms:
> >http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/files/39<http://bazaar.launchpad.net/%7Ewalles/drain-o-meter/trunk/files/39>
>
> > I now have a working implementation with a background service:
> >http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/files/57<http://bazaar.launchpad.net/%7Ewalles/drain-o-meter/trunk/files/57>
>
> > Suggestions on how I should *really* be doing welcome :-).
>
> >  Cheers //Johan
>
> > On 9 Sep, 16:47, Mark Murphy  wrote:
> > > Walleswrote:
> > > > I'll use a Service instead of an Alarm and keep it running in the
> > > > background.  That way I can keep track of it myself.
>
> > > Please don't. For starters, it won't work, since the service may get
> > > killed off by the user or the system. Also, while the service is in
> > > memory, you are taking up one process' worth of RAM.
>
> > > If you could explain to us what the effect is you are trying to achieve
> > > (versus low-level technical statements, like "not to overwrite an
> > > existing alarm with a new one"), we might be able to suggest alternative
> > > patterns.
>
> > > --
> > > Mark Murphy (a Commons Guy)http://commonsware.com|
> >http://twitter.com/commonsguy
>
> > > _Android Programming Tutorials_ Version 1.0 In Print!
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Probing for an already set Alarm?

2009-09-15 Thread Walles

On 16 Sep, 05:26, Beth  wrote:
> What does the background service do, exactly?  Sorry, I don't really
> want to sort through the two versions of your code.

It has a thread that wakes up regularly to take a snapshot of /proc:
http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/annotate/head%3A/src/net/launchpad/drainometer/StatisticsCollector.java

private void doPeriodicUpdates() throws InterruptedException {
// Make two updates in quick succession to begin with to
get
// two samples.  Two samples are necessary for us to
display
// any data.
doUpdate();
if (done()) {
return;
}

Thread.sleep(15000);
doUpdate();

while (!done()) {
   Thread.sleep(SAMPLING_INTERVAL_SECONDS * 1000);
   doUpdate();
}
}


> What I did see in the alarm version leads me to suggest that you can
> set a repeating alarm in your Activity after collecting the initial
> data rather than set a new Alarm each time your broadcast receiver is
> called.  If you describe what went wrong trying to use the alarm
> manager maybe you can drop the excess baggage of a background
> service.

With the alarm implementation, starting the UI means taking one
sample.

What I really want is for the samples to be taken independently of
when the UI starts.

Pseudo code for the UI:
1. Set an updating alarm in 15s.
2. Show UI based on existing data.

Pseudo code for the sampler:
1. Take a sample and store it in a database.
2. Schedule a new alarm in 10 minutes (exact number still being
tuned).

The first time the UI code is called (when no sampling has occurred),
everything is fine.  Sampling starts after 15s.

The second time the UI code is called (when we have been sampling for
a while), a new alarm is set to trigger a new sample in 15s.  The
existing alarm (in 10 minutes) is thrown out implicitly by the
system.  The setting of this new alarm, and the throwing out of the
existing alarm is what I want to avoid.

> Since you are trying to measure performance, you really
> ought to go the extra mile to drop the extra process and be sure your
> app does all it should to mitigate any performance impact.

If I do it badly it will show up in the stats, and I even highlight
the Drain-O-Meter itself in the listing for this precise reason.
Overhead is still OK :-).

  Cheers //Johan

> On Sep 15, 5:02 am, Walles  wrote:
>
> > Good point :-), here's the plan:
>
> > I'm writing an app to find out what apps are using the most CPU time
> > (which I hope will correlate with battery drain).  It's possible to
> > get a snapshot picture of this by looking at 
> > /proc:http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/annotate/head...
>
> > A single snapshot picture will however miss apps that start, run for
> > some time and then exit.
>
> > So what I want to do is to take *regular* snapshots.  I take the
> > difference between the last two snapshots and add the difference to a
> > process name -> number of ticks Map.
>
> > Snapshotting rules are:
> > * Snapshots should be taken at regular intervals.
> > * The first two snapshots should be taken in quick succession to be
> > able to quickly present the first measurement to the user.
> > * It must be possible for an UI app to look at the result of the
> > snapshotting.
>
> > To get the whole thing going, I'm letting the UI part of the
> > application start the sampler in the background.  When the sampling is
> > first started it needs to take two snapshots quickly (see above).  The
> > rest of the samples should be taken at longer intervals.
>
> > I first tried to do this using alarms, but I didn't manage to get the
> > "two quick samples first and the rest further apart" behavior with
> > alarms:http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/files/39
>
> > I now have a working implementation with a background 
> > service:http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/files/57
>
> > Suggestions on how I should *really* be doing welcome :-).
>
> >   Cheers //Johan
>
> > On 9 Sep, 16:47, Mark Murphy  wrote:
>
> > > Walleswrote:
> > > > I'll use a Service instead of an Alarm and keep it running in the
> > > > background.  That way I can keep track of it myself.
>
> > > Please don't. For starters, it won't work, since the service may get
> > > killed off by the user or the system. Also, while the service is in
> > > memory, you are taking up one process' worth of RAM.
>
> > > If you could explain to u

[android-developers] Re: Probing for an already set Alarm?

2009-09-15 Thread Walles

Good point :-), here's the plan:

I'm writing an app to find out what apps are using the most CPU time
(which I hope will correlate with battery drain).  It's possible to
get a snapshot picture of this by looking at /proc:
http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/annotate/head%3A/src/net/launchpad/drainometer/proc/ProcSnapshot.java

A single snapshot picture will however miss apps that start, run for
some time and then exit.

So what I want to do is to take *regular* snapshots.  I take the
difference between the last two snapshots and add the difference to a
process name -> number of ticks Map.

Snapshotting rules are:
* Snapshots should be taken at regular intervals.
* The first two snapshots should be taken in quick succession to be
able to quickly present the first measurement to the user.
* It must be possible for an UI app to look at the result of the
snapshotting.

To get the whole thing going, I'm letting the UI part of the
application start the sampler in the background.  When the sampling is
first started it needs to take two snapshots quickly (see above).  The
rest of the samples should be taken at longer intervals.

I first tried to do this using alarms, but I didn't manage to get the
"two quick samples first and the rest further apart" behavior with
alarms:
http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/files/39

I now have a working implementation with a background service:
http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/files/57

Suggestions on how I should *really* be doing welcome :-).

  Cheers //Johan

On 9 Sep, 16:47, Mark Murphy  wrote:
> Walleswrote:
> > I'll use a Service instead of an Alarm and keep it running in the
> > background.  That way I can keep track of it myself.
>
> Please don't. For starters, it won't work, since the service may get
> killed off by the user or the system. Also, while the service is in
> memory, you are taking up one process' worth of RAM.
>
> If you could explain to us what the effect is you are trying to achieve
> (versus low-level technical statements, like "not to overwrite an
> existing alarm with a new one"), we might be able to suggest alternative
> patterns.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> _Android Programming Tutorials_ Version 1.0 In Print!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Getting longer stack traces from DDMS?

2009-09-11 Thread Walles

I read this blog about how to use DDMS to track memory allocations.
http://android-developers.blogspot.com/2009/02/track-memory-allocations.html

Using those instructions, I was able to get allocation stack traces.

Unfortunately the stack traces only go 8 deep (at least when running
against the simulator), and that's too little for me to know where in
my code the allocations really originate.

How can I raise the limit from 8 to something higher?

  Regards //Johan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to improve existing Android applications?

2009-09-11 Thread Walles

The answer I was really looking for was this:
http://source.android.com/using-eclipse

Having a pointer to there from the developer FAQ would be nice.

  /J

On 18 Aug, 10:11, Walles  wrote:
> How do I get (for example) the Android Calendar app into Eclipse so I
> can modify it and send in patches?
>
> There's a ton of documentation on how to create *new* apps, but so far
> I've been unable to find any info on how to get *existing* apps into
> Eclipse.  And my own attempts have gone so-so :-p.
>
> A good place for this information would be the developer FAQ for
> example:http://developer.android.com/guide/appendix/faq/commontasks.html
>
>   Regards //Johan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Probing for an already set Alarm?

2009-09-09 Thread Walles

I'll use a Service instead of an Alarm and keep it running in the
background.  That way I can keep track of it myself.

Thanks for the input!

  Cheers /J

On 8 Sep, 07:34, Walles  wrote:
> Hi!
>
> How can I probe for whether a specific alarm has been set?  I set the
> alarm as illustrated below, but how can I ask the OS whether or not
> the below code has been called?  The point is not to overwrite an
> existing alarm with a new one.
>
>     public static void scheduleNextUpdate(Context context, long
> delay_seconds) {
>         Intent intent = new Intent(context, Updater.class);
>         PendingIntent pendingIntent =
>             PendingIntent.getBroadcast(context, 0, intent, 0);
>         AlarmManager alarmManger =
>             (AlarmManager)context.getSystemService
> (Context.ALARM_SERVICE);
>
>         long now = System.currentTimeMillis();
>         long later = now + delay_seconds * 1000;
>         Log.d(DrainOMeter.LOGGING_TAG, "Scheduling next update in "
>               + delay_seconds
>               + "s at "
>               + new Date(later));
>         alarmManger.set(AlarmManager.RTC, later, pendingIntent);
>     }
>
> Full sources available 
> athttp://bazaar.launchpad.net/~walles/drain-o-meter/trunk/annotate/head...
> if needed.
>
>   Thanks //Johan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Probing for an already set Alarm?

2009-09-07 Thread Walles

Hi!

How can I probe for whether a specific alarm has been set?  I set the
alarm as illustrated below, but how can I ask the OS whether or not
the below code has been called?  The point is not to overwrite an
existing alarm with a new one.

public static void scheduleNextUpdate(Context context, long
delay_seconds) {
Intent intent = new Intent(context, Updater.class);
PendingIntent pendingIntent =
PendingIntent.getBroadcast(context, 0, intent, 0);
AlarmManager alarmManger =
(AlarmManager)context.getSystemService
(Context.ALARM_SERVICE);

long now = System.currentTimeMillis();
long later = now + delay_seconds * 1000;
Log.d(DrainOMeter.LOGGING_TAG, "Scheduling next update in "
  + delay_seconds
  + "s at "
  + new Date(later));
alarmManger.set(AlarmManager.RTC, later, pendingIntent);
}

Full sources available at
http://bazaar.launchpad.net/~walles/drain-o-meter/trunk/annotate/head%3A/src/net/launchpad/drainometer/Updater.java#L72
if needed.

  Thanks //Johan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] How to improve existing Android applications?

2009-08-18 Thread Walles

How do I get (for example) the Android Calendar app into Eclipse so I
can modify it and send in patches?

There's a ton of documentation on how to create *new* apps, but so far
I've been unable to find any info on how to get *existing* apps into
Eclipse.  And my own attempts have gone so-so :-p.

A good place for this information would be the developer FAQ for
example:
http://developer.android.com/guide/appendix/faq/commontasks.html

  Regards //Johan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---