[android-developers] Re: Magnetic Sensor

2011-04-20 Thread ip332
This method does not return magnetic sensor output but calculates
parameters of the Earth magnetic field model in a given point at a
certain time (you can Google for IGRF abbreviation to see details).

If you want to get magnetic sensor output then check SensorManager:
check http://developer.android.com/reference/android/hardware/SensorManager.html

On Apr 20, 12:10 pm, Thisara Rupasinghe thisara...@gmail.com wrote:
 Hello,

 When I try to use magnetic sensor it need physical location to find the
 megnetic strength. But since it is going to measure the magnetic strength
 why does it need the physical location? Can anybody help me with this.

 public GeomagneticField (float gdLatitudeDeg, float gdLongitudeDeg, float
 altitudeMeters, long timeMillis)

 --
 Thanks  Regards,
 Thisara.

-- 
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: String to Float Performance Ideas

2011-04-14 Thread ip332
Here is a simple class to convert a string in from 1234.4567 into a
floating point.
It doesn't support hexadecimal or 1E23 notations but it is here to
show the idea
===
public class String2Float {
final int max_exp = 38;
final int max_str_len = 20;
float [] values;
char [] buffer;

public String2Float() {
buffer = new char [max_str_len + 1];
values = new float [max_exp + 1];
values[ 0 ] = 1;
for( int i = 1; i  max_exp; i++ ) {
values[ i ] = values[ i - 1 ] * 10;
}
}

public float Value(String str) {
int len = str.length();
if( len  max_str_len )
len = max_str_len; // ToDo: add proper error handling
// extract all characters into the local buffer
str.getChars(0, len - 1, buffer, 0);
// find decimal point
int point_idx = len;
for( int i = 0; i  len; i++ ) {
if( buffer[i] == '.' ) {
point_idx = i;
break;
}
}
// process all digits before the decimal point
float res = 0;
for( int i = 0; i  point_idx ; i++ ) {
int digit = buffer[i] - '0';
float value = digit * values[point_idx - i - 1];
res += value;
}
// process all digits after the decimal point
for( int i = point_idx + 1; i  len; i++ ) {
int digit = buffer[i] - '0';
float value = digit / values[i - point_idx];
res += value;
}
return res;
}
}


On Apr 14, 4:47 pm, Paul pmmen...@gmail.com wrote:
 OK, have stripped the FloatingPointParser bare, but can't run it as
 the native method, parseFltImpl() is throwing an
 UnsatisfiedLinkError...

 Maybe a silly question, but any ideas what to do from here?

 On Apr 14, 4:57 pm, Paul pmmen...@gmail.com wrote:







  Sorry, should have mentioned this, this is 2.2 running on a Galaxy
  Tab.

  Based on Mark and Kostya's suggestions, I might just try to trim the
  source and see what I can come up with - might be easier than managing
  a mapping structure and will surely be lighter memory wise.

  Will post back here with results as I have them!

  Paul

  On Apr 14, 4:26 pm, Dianne Hackborn hack...@android.com wrote:

   What version of the platform are you running on?  It looks like in the
   current source most of the function is written in native code, but there 
   is
   no native code in your profiling.  I don't work on Dalvik, so I don't know
   when the native impl appeared.

   If this is the original Harmony implementation, it is probably way
   over-engineered and inefficient. :)  If your numbers are normally of the
   form x.yyy you could try writing your own parser that parses that 
   form
   as efficiently as possible, and bail to the generic impl if it finds
   something it can't handle.

   You certainly should be able to write something that doesn't have a 
   $#^%!!
   StringBuilder involved (good ghod!).

   On Thu, Apr 14, 2011 at 11:43 AM, Paul pmmen...@gmail.com wrote:
Ah, I see, create a kind of mapping from String - float, and first
check the mapping before performing the conversion?

Here is what traceview is telling me for the calls to Float.valueOf():

java/lang/Float.valueOf (Ljava/lang/String;)Ljava/lang/Float;
 * self = 1.9%
 * java/lang/Float.parseFloat (Ljava/lang/String;)F = 94.3%

 ** self = 1.3%
 ** org/apache/harmony/luni/util/FloatingPointParser.parseFloat (Ljava/
lang/String;)F = 98.7%

 *** self = 6.5%
 *** org/a.../h.../luni/util/FloatingPointParser.initialParse (Ljava/
lang/String;I)Lorg/a.../h.../luni/util/FloatingPointParser
$StringExponentPair = 58.7%

  self = 29.9%
  a bunch of StringBuilder calls ~= 60%

 *** java/lang/String.toLowerCase ()Ljava/lang/String = 26.8%

 * java/lang/Float.valueOf (F)Ljava/lang/Float; = 3.8%

 ** self = 48.4%
 ** java/lang/Float.init (F)V = 51.2%

 *** self = 69.7%
 *** java/lang/Number.init ()V = 30.3%

Paul

On Apr 14, 2:20 pm, Dianne Hackborn hack...@android.com wrote:
 I think this may be what Marcin was suggesting -- if the same float 
 value
 tends to appear multiple times, then when you parse a new one put it 
 into
a
 cache.  When you read strings, first see if the string is already in 
 the
 cache to retrieve the previously parsed float value for it.

 Also can you get profiling data for where most of the time is spent
inside
 of Float.parseFloat()?  In at least the 

[android-developers] Re: String to Float Performance Ideas

2011-04-14 Thread ip332
public class String2Float {
final int max_exp = 38;
final int max_str_len = 20;
float [] values;
char [] buffer;

public String2Float() {
buffer = new char [max_str_len + 1];
values = new float [max_exp + 1];
values[ 0 ] = 1;
for( int i = 1; i  max_exp; i++ ) {
values[ i ] = values[ i - 1 ] * 10;
}
}

public float Value(String str) {
int len = str.length();
if( len  max_str_len )
len = max_str_len; // ToDo: add proper error handling
// extract all characters into the local buffer
str.getChars(0, len - 1, buffer, 0);
// find decimal point
int point_idx = len;
for( int i = 0; i  len; i++ ) {
if( buffer[i] == '.' ) {
point_idx = i;
break;
}
}
// process all digits before the decimal point
float res = 0;
for( int i = 0; i  point_idx ; i++ ) {
int digit = buffer[i] - '0';
float value = digit * values[point_idx - i - 1];
res += value;
}
// process all digits after the decimal point
for( int i = point_idx + 1; i  len; i++ ) {
int digit = buffer[i] - '0';
float value = digit / values[i - point_idx];
res += value;
}
return res;
}
}


On Apr 14, 5:02 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Thu, Apr 14, 2011 at 7:47 PM, Paul pmmen...@gmail.com wrote:
  OK, have stripped the FloatingPointParser bare, but can't run it as
  the native method, parseFltImpl() is throwing an
  UnsatisfiedLinkError...

  Maybe a silly question, but any ideas what to do from here?

 Start from scratch, as Gaz Davidson did here:

 http://bitplane.net/2010/08/java-float-fast-parser/

 Or, as the last comment on that blog post indicates, grab the latest
 code from Harmony and try it.

 Or, roll your own String-Float using JNI and the NDK.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 Android Training in NYC:http://marakana.com/training/android/

-- 
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: String to Float Performance Ideas

2011-04-14 Thread ip332
Sorry about double posting :(
BTW the performance of this method is about 10 times better.

-- 
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: Launching Google maps from another app

2011-04-02 Thread ip332
You are mixing several tasks into one question. Split them and it will
be much easier:
1. Geocoding (convert street address into lat,long pair) is the first
task. But all items in your set of addresses should be converted
into x,y pairs.
2. Each such pair (lat/long) should be used in the Overlay to show
some marker. Which exactly marker is up to you, and there are plenty
of examples in the internet about Overlays.
3. When you have one x,y you can use it as map center to start
MapActivity.   When you have multiple locations - you can use the
first x,y or the average. You can also change map scale to make all
markers visible.


On Apr 1, 1:09 am, S ohri.sac...@gmail.com wrote:
 Hi,

 I want to launch the native google map app from my application and
 pass some set of addresses so that google maps can show all the
 addresses as markers.

 All the examples that I have seen are where we can pass single address
 (be a lat/long or the address) but there is no mention of the case
 where we need multiple addresses to be displayed.

 For single address these are the format I see on internet:

 String geoUriString =
 getResources().getString(R.string.map_location);
 Uri geoUri = Uri.parse(geoUriString);
 Intent mapCall = new Intent(Intent.ACTION_VIEW, geoUri);
 startActivity(mapCall);

 Map Location can be: 1.STRING name=map_locationgeo:0,0?q=123 +
 abc street + def city+TX+ 75038 STRING

 Any help here will be appreciated.

-- 
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: Difference between Phone and Tablet

2011-03-31 Thread ip332
Yes, the main and only critical difference is the actual screen size.
It sounds a minor issue from the technical point of view but means
completely different end user expectations (and eventually the
application's UI)

On Mar 31, 4:38 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Thu, Mar 31, 2011 at 7:33 PM, Manish Garg mannishga...@gmail.com wrote:
  I have created an application for the 2.2 version, now it needs to be
  run on one of the tablet. Because of it I need to know what should i
  check in my application where it may fail. My target tabs, Dell
  Streak, Samsung galaxy and mortrol XOOM both have call functionality.

 The Motorola XOOM does not have call functionality.

 http://commonsware.com/blog/2011/02/25/xoom-permissions-android-marke...

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 Android 3.0 Programming Books:http://commonsware.com/books

-- 
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: Any way to detect if the GPS data is real

2011-03-25 Thread ip332
Request updates from the GPS_PROVIDER and you will never get updates
from other providers.
It is impossible to add a mock location provider with the name which
is already registered.

On Mar 25, 3:53 pm, lbendlin l...@bendlin.us wrote:
 I haven't done any GPS injection yet. Maybe there is a field in the NMEA
 stream that is unique to the genuine GPS.

-- 
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: sensor HAL

2011-03-23 Thread ip332
Android source code tree.

On Mar 23, 4:52 am, palanivel.durais...@googlemail.com
palanivel.durais...@googlemail.com wrote:
 Hi,

 I am developing  gyro sensor driver for Android 2.3.1(gingerbread).
 I would like to develop sensor HAL module for accessing the driver.
 Where can I find the sample code for sensor HAL?

 Thanks
 Palanivel

-- 
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: SIGSEGV on free()

2011-03-22 Thread ip332
The error usually indicates allocated memory overrun somewhere in the
past.
IMHO you use strlen() on UTF8 string therefore the strcpy() overwrites
the amount of memory allocated by malloc.
Increase the allocation size 5 times to check this theory - if the
problem has gone then you need to review string conversion.
Sorry, don't have time to study your code in details.
An advise for you: try to keep memory management on Java side. It will
simplify your life a lot.

On Mar 22, 1:26 am, Dewr wind8...@gmail.com wrote:
 I have tested it on Galaxy S and it worked well on Galaxy S (2.2). I have
 not tried it on another Nexus One in order to know if my Nexus One is
 faulty.

 and it seems like that AssetFileDescriptor is not the source of the problem,
 because the problem is still ocurring while I didn't access asset files
 directly but accessing copied ones.







 On Fri, Feb 25, 2011 at 1:10 PM, Dewr wind8...@gmail.com wrote:
  it often causes SIGSEGV on third for-loop. but just a moment ago SIGSEGV on
  fourth loop.

  for ( i = 0 ; i  4 ; i++ ) {
  sprintf (temp, %s%s, header[i], index[fileno[i]]);
  *strBuf = getTextByIndex(filebuf, temp);* *//malloc() in this
  function.*
  if (strBuf == NULL)
  buf_output[i] = NULL;
  else

  {
  buf_output[i] = (*gEnv)-NewStringUTF(gEnv, strBuf);
  *free(strBuf);*
  }
  }

  On Thu, Feb 24, 2011 at 1:15 PM, Dewr wind8...@gmail.com wrote:

  Hello, I am porting a C program.

  The problem I've met is SIGSEGV on free(). I can't see what's the root
  cause of it.
  it doesn't occur sometimes, but very often.

  I am testing it on NexusOne 2.2.1
  I am using Android NDK r5b and Android SDK and Eclipse ADT and Cygwin.

  I am using *android.content.res.AssetFileDescriptor* to read assets in C
  modules.

  Here is the messages in ndk-gdb when the problem appears.

  (gdb) c
  Continuing.

  Breakpoint 2, Java_kr_co_pkbio_Unse_DangSaJuShinSal (env=0xaa50,
  obj=0x4495b970)
  at
  C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/jni/unse.c:1
  83
  *1083free(strBuf);*
  (gdb) next

  *Program received signal SIGSEGV, Segmentation fault.*
  *0xafd11c80 in __libc_android_abort ()*
 from
  C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
  meabi/libc.so
  (gdb) bt
  #0  0xafd11c80 in __libc_android_abort ()
 from
  C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
  meabi/libc.so
  #1  0xbec233bc in ?? ()
  Cannot access memory at address 0xc
  (gdb) quit

  Here is the Java source code...

  public static FileInfoForNativeCode openAssets(String fname) {
  if (Constants.VERBOSE_LOGS)
  Log.d(TAG, openAssets(+fname+));

  *AssetFileDescriptor myDescriptor = null;*
  try {
  myDescriptor = context.getAssets().openFd(fname+.jet);
  } catch (IOException e) {
  e.printStackTrace();
  return null;
  }
  FileDescriptor fd = myDescriptor.getFileDescriptor();
  long off = myDescriptor.getStartOffset();
  long len = myDescriptor.getLength();

  if (Constants.VERBOSE_LOGS)
  Log.d(TAG, fd:+fd+ off:+off+ len:+len);

  return new FileInfoForNativeCode(off, len, fd);
  }

  Here is the C source code...

  char* getTextByIndex (TextFileBufType *filebuf, char *index) {
  #define _INDEX_PREFIX_'@'
  inti, j, lenBuf;
  char*result;
  charindexPrefix = _INDEX_PREFIX_;
  intlenIndexPrefix = utf8len( indexPrefix );
  intlenIndex = strlen(index);

  for ( i = 0 ; i  filebuf-total ; i++ ) {
  *//__android_log_print(ANDROID_LOG_DEBUG,TAG, JNI : %d -
  %s, i, filebuf-text[i]);*

  if ( memcmp (filebuf-text[i], indexPrefix, lenIndexPrefix) != 0
  )
  continue;

  if ( memcmp (filebuf-text[i]+lenIndexPrefix, index, lenIndex) !=
  0 )
  continue;

  lenBuf = 0;
  lenBuf += strlen(filebuf-text[i]);
  lenBuf++;
  for ( j = i+1 ; j  filebuf-total ; j++ ) {
  if ( memcmp (filebuf-text[j], indexPrefix, lenIndexPrefix)
  == 0 )
  break;

  lenBuf += strlen(filebuf-text[j]);
  lenBuf++;
  }

  *result = malloc(lenBuf);*
  result[0] = 0;
  strcat(result, filebuf-text[i]);
  strcat(result, \n);
  for ( j = i+1 ; j  filebuf-total ; j++ ) {
  if ( memcmp (filebuf-text[j], indexPrefix, lenIndexPrefix)
  == 0 )
  break;

  strcat(result, filebuf-text[j]);
  strcat(result, \n);
  }

  *//__android_log_print(ANDROID_LOG_DEBUG,TAG, JNI : %d!!! -
  %s, i, filebuf-text[i]);*
  *return result;*
  }

  return NULL;

  #undef _INDEX_PREFIX_
  }

  inline void readyFileInFile 

[android-developers] Re: property settings in Java and native C code

2011-03-18 Thread ip332
It's impossible.
Unless you have a JNI which is special case of Java...

On Mar 18, 12:40 am, Sun Ray-B1 b17...@freescale.com wrote:
 Hi All,

 I want to set the property in Java code and get the property in C code. Is 
 this available?

 What I used is as below:

 1.       Set the  property to 0x2
                                   mPowerControl = getInt(POWER_CONFIG, 
 0x0);//get the configuration value of power
                                   System.setProperty(rw.power.config, 
 String.valueOf(mPowerControl));

 2.       Get the property, always  to be 1, as I set in the init.rc
 property_get(rw.power.config, propBuf, 0);)

 3.       Get the property through adb shell, it's same with the value by 
 property_get
 getprop rw.power.config

 Thanks,
 Ray

-- 
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: Tracing Geo Location and saving them into file from start of a cal to end call duration

2011-03-18 Thread ip332
I guess the question was about location, not the GeoCoder class.

Yes, technically you can do that. The tricky part is that if the GPS
fix was not available at the moment of the incoming call start then
there is a good chance to not have a fix till its end. You could use
position from the WiFi AP but it is available only in certain area and
it is not a trivial task to differentiate WiFi position from the cell
position.



-- 
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: receive GPS enable/disable settings event

2011-03-18 Thread ip332
locationManager.addGpsStatusListener(statusListener);

On Mar 18, 10:07 am, andrefy andr...@gmail.com wrote:
 what about use the LocationListener with a long time period, so it will not
 have a relative important impact at  you app, the GPS status change always
 will let you know when it happens, even if it is between the update time
 period

-- 
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: GLES20 background bitmap on just 2 triangles kills 35 fps

2011-03-15 Thread ip332
The size is not an issue, the blending type - also.
Could you provide a complete source code ?

On Mar 15, 5:41 am, Alex Rempel alexey.rem...@googlemail.com wrote:
 On Mar 15, 11:36 am, alan a...@birtles.org.uk wrote:

  have you tried the draw texture extension?

 Tested it already, there is a GL_INVALID_ENUM error on using
 glTexParameteriv with GL22Ext.GL_TEXTURE_CROP_RECT_OES. I'd say the
 extension doesn't exist in GLES20 context.

 Are there maybe some other possible problems? Or is it possible that
 the GLES20 context has worse performance on android than GL11
 context?

-- 
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: GLES20 background bitmap on just 2 triangles kills 35 fps

2011-03-15 Thread ip332
In my previous project on Windows CE the bottleneck of the GL
performance was not in the number of triangles or textures size but in
the synchronization between load/draw threads.
You mentioned some problems you have overcome already (thread/
events...) and I simply wanted to see if there are no issues there.

BTW: how did you get 60fps ? How many triangles did you have ? how
many textures (and their size) ?


On Mar 15, 9:01 am, Alex Rempel alexey.rem...@googlemail.com wrote:
 On Mar 15, 4:27 pm, ip332 iprile...@gmail.com wrote:

  The size is not an issue, the blending type - also.
  Could you provide a complete source code ?

 It's not that easy to do as it is not a simple test code sample...
 What exactly would You like to see?
 Info: GL_RENDERER is Adreno 200

 Here is the loading part...
 +++
 int[] id = new int[1];
 GLES20.glGenTextures(1, id, 0);
 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, id[0]);
 GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
 GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
 GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
 GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
 GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
 GLES20.GL_CLAMP_TO_EDGE);
 GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
 GLES20.GL_CLAMP_TO_EDGE);
 GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
 ...
 bitmap.recycle();
 bitmap = null;
 +++

 Here is the setting to shader part:
 +++
 int location = GLES20.glGetUniformLocation(m_curProgram.id(),
 strShaderComponent);
 GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, gl_texture_id);
 GLES20.glUniform1i(location, 0);
 +++

-- 
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: GLES20 background bitmap on just 2 triangles kills 35 fps

2011-03-15 Thread ip332
2D shoudl be much faster because it usually about transferring pixels
(usually organized into a scan lines) from one bitmap to another when
3D requires a lot of calculations with floating point and it should be
slower than 2D even with HW support.
On the other side, 35 fps vs. 57 is not too bad if you will get the
same performance for the real app.

Try to model the real app output (with respect to the number of
triangles, size of textures and blending operations). May be you will
still get the same 35 fps :)

On Mar 15, 12:48 pm, Alex Rempel alexey.rem...@googlemail.com wrote:
 I just adapted my rendering thread to support a canvas instead of EGL
 context and I do absolutely the same; showing an fps text and blitting
 a background texture.
 Guess what: showing the text only I get 58fps, adding the background
 picture I get... 57fps!

 Now I am officially and very seriously pissed off. I hope that I am
 just not smart enough to use GLES20 well, otherwise it seems that if
 you want to blit 2D graphics - you take Canvas; and if and ONLY IF you
 want many triangles in 3D, then you take OpenGL.

 Shouldn't OpenGL be always at least as fast as the 2D API provided by
 the Canvas?

-- 
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: Undo Feature in Drawing App - Need best methodology, not looking for code

2011-03-15 Thread ip332
1) You can save bitmap to the file and keep only it's reference in the
memory
2) You can use RLE enconding (i.e. save differences between  old and
new frame.
3) You can store one original bitmap and put each drawing command into
a linked list (i.e. set color black, set pen width 0, draw line
from x1,y1 to x2,y2). When you need to undo step N you remove the
last operation from this list, take the original bitmap and apply all
commands from the list sequentially. If the operations are time
consuming you can limit the size of this list. Once it reaches the
limit, you take original bitmap, apply the changes from the first item
in the list, remove this first element and save result as new
original bitmap.


On Mar 15, 1:03 pm, Matt M matthew.mag...@gmail.com wrote:
 Hello,

 My application includes a drawing feature and I would like the add the
 ability to undo. The undo feature currently in place simply loads
 the bitmap from the last saved file, so no matter how many changes
 they make to their drawing undo will revert it back to the way it
 was before any changes were made.

 What I want to do now is make it more like the undo feature we are
 used to in modern applications, so that it does not go back to the way
 the file was when we first opened it, rather it goes back in various
 steps during our editing (which can be quite numerous).

 My idea is to save the current bitmap in a linked list after every
 occurrence of finger down, finger up. Thus every time the user lifts
 their finger from the screen the bitmap will be added to the linked
 list. Then of course when undo is selected the bitmap at the top of
 the stack will be loaded. The only problem is if the user makes 20,
 30, 40+ changes to their drawing that is a lot of bitmaps to keep
 references to, am I right? I see out of memory errors coming. Any
 ideas for alternatives?

 Thank you!

 Matt.

-- 
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: Caching of sensor events

2011-03-14 Thread ip332
 How does android process events in case of high CPU load?
Same way as in the low CPU load. Read data, calls your sensor
listener, waits a certain amount of time to provide events at a
desired rate.
Obviously the details depend on the sensors HAL implementation for a
given phone. I've seen a phone where this module did some heavy work
by itself and eats up to 45% of CPU.
Some phones allows request sensors updates with 0 delay which results
in continuous reading and 100% CPU load.
But most important: Android is not a real time platform dedicated to
the data processing.


On Feb 9, 8:06 am, Heiko heiko.wi...@gmail.com wrote:
 Hi,

 I'm currently testing the impact of heavy CPU workload on
 accelerometer sampling frequency. It appears, that when CPU workload
 is high, the samplerate oscillates between higher and lower than
 average values. I'm also storing the timestamp diff between two events
 and the test reveals, that there is also an oscillation here.

 You can see the time diff between sensor events 
 here):http://cl.ly/2S3o2T0w3A1W181i3g3F

 N is the phase with normal CPU load, Y the phase with high CPU load
 (around 95%+).

 The influence on the sample rate can be seen in this 
 chart):http://cl.ly/1T253P041O0R2m1U3Z1V

 How does android process events in case of high CPU load? Does it
 collect events and then sends many of them in a burst phase to the
 handler of an app?

 Best
 Heiko

-- 
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: Google Maps image overlay not visible

2011-03-14 Thread ip332
 How to covert this to the correct microdegrees for GeoPoint()?
http://www.earthpoint.us/Convert.aspx#PositionColumn

Do not decode bitmap inside drawing handler because it must be as
quick as possible.
Since this resource is unlikely to be changed between two drawing
calls it is better to load this bitmap during onCreate() or onResume()
processing.


On Mar 13, 12:26 am, Bastiaan bastiaa...@gmail.com wrote:
 It must be an overlay. It's a ski piste map.

 If i use the following GeoPoints than the overlay is visible, but not
 on the correct location:

 min = new GeoPoint(45321389,6294167);
 max = new GeoPoint(45423889,6401667);

 If i use this GeoPoints than it's NOT visible:

 min = new GeoPoint(45285650,6174317);
 max = new GeoPoint(45197750,6306150);

 The correct points are (in the programs MapEdit and Google Maps):
 Left upper corner: N45°17.139' E6°10.459'
 Right lower corner: N45°11.865' E6°18.369'

 How to covert this to the correct microdegrees for GeoPoint()?

 On 12 mrt, 05:02, lbendlin l...@bendlin.us wrote:







  Does it have to be an overlay? If it's just an image then you can
  simply add it as a view to the mapView.

  An overlay is just a layer. Unless you fill it with objects, nothing
  will show.

  On Mar 10, 1:54 pm, Bastiaan bastiaa...@gmail.com wrote:

   Hello,

   I want to overlay a map image (.jpg) over the Google Maps mapview.
   The problem is: The overlay image is not showing, who knows what's the
   problem?

   There is no error in logcat and the MapView is working.

   The code:

   package nl.ultimo.android.skikaart;

   import java.util.List;
   import com.google.android.maps.GeoPoint;
   import com.google.android.maps.MapActivity;
   import com.google.android.maps.MapController;
   import com.google.android.maps.MapView;
   import com.google.android.maps.Overlay;

   import android.graphics.Bitmap;
   import android.graphics.BitmapFactory;
   import android.graphics.Canvas;
   import android.graphics.Point;
   import android.graphics.Rect;
   import android.os.Bundle;

   public class MapsActivity extends MapActivity
   {
            Bitmap          bmp;    //Loaded bitmap in memory
        GeoPoint        min;    //Top left corner (lat/long)
        GeoPoint        max;    //Right bottom corner (lat/long)

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

           float lat1 = 45.19775f;
           float lng1 = 6.28418333f;
           float lat2 = 45.2636667f;
           float lng2 = 6.17431667f;

           min = new GeoPoint((int)(lat1 * 1E6), (int)(lng1 *
   1E6));               // bounding rectangle
           max = new GeoPoint((int)(lat2 * 1E6), (int)(lng2 * 1E6));

           MapView mapView = (MapView) findViewById(R.id.mapView);
           MapController ctrl = mapView.getController();

           int x = (min.getLongitudeE6() + max.getLongitudeE6())/ 2;  //
   Select map center
           int y = (min.getLatitudeE6() + max.getLatitudeE6())/ 2;

           ctrl.setCenter(new GeoPoint(y,x));
           ctrl.setZoom(12);                 //Set scale
           mapView.setBuiltInZoomControls(true); //Enable zoom controls

           //Add overlay
           MapOverlay mapOverlay = new MapOverlay();
           ListOverlay listOfOverlays = mapView.getOverlays();
           listOfOverlays.clear();
           listOfOverlays.add(mapOverlay);

           mapView.invalidate();
       }

       class MapOverlay extends com.google.android.maps.Overlay
       {
           @Override
           public boolean draw(Canvas canvas, MapView mapView, boolean
   shadow, long when)
           {
               super.draw(canvas, mapView, shadow);

               //Translate the GeoPoint to screen pixels
               Point screenPts = new Point();
               mapView.getProjection().toPixels(min, screenPts);

               //The overlay image
               Bitmap bmp = BitmapFactory.decodeResource(getResources(),
   R.drawable.skikaart);

               //Prepare two rectangles (pixels)
               Point top_left = new Point();
   mapView.getProjection().toPixels(min, top_left);
               Point bottom_right = new Point();
   mapView.getProjection().toPixels(max, bottom_right);

               Rect src = new Rect( 0,0,bmp.getWidth() - 1,
   bmp.getHeight() - 1 );
               Rect dst = new Rect( top_left.x,
   bottom_right.y,bottom_right.x,top_left.y );

               canvas.drawBitmap(bmp, src, dst, null);

               return true;
           }
       }

       @Override
       protected boolean isRouteDisplayed() {
           return false;
       }

   }

-- 
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] Re: GLES20 background bitmap on just 2 triangles kills 35 fps

2011-03-14 Thread ip332
Blending type should not affect performance when Open GL has HW
support (i.e. most of the today's Android phones)
How big is the PNG? How and when do you load it ?

On Mar 13, 8:52 am, Alex Rempel alexey.rem...@googlemail.com wrote:
 Hi piplz,

 I'm trying to develop a little LiveWallpaper engine for OpenGL GLES20,
 for now just in 2D. After I got around all the thread/event-problems
 because of the wallpaper issues and after I booh'ed at the 60fps I now
 inly have one grudge:

 Drawing just one single big PNG loaded as GL_RGBA.UNSIGNED_BYTE on 2
 triangles representing the background takes away 35 fps, regardless of
 blending mode being enabled or not!

 What I tried:
 - driving the source image resolution down doesn't help, it's the size
 of the quad to blit
 What I could try:
 - binding the big image just once after loading instead of doing it
 in every frame

 Is there something I might have missed?

-- 
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: Nexus S and gingerbread Sensor events — Which sensor uses what hardware ?

2011-03-14 Thread ip332
Here is the list of devices and the corresponded Sensor.TYPE_XXX:
1.Accelerometer (TYPE_ACCELEROMETER, TYPE_GRAVITY and
TYPE_LINEAR_ACCELERATION)
2.Magnetic field sensor (TYPE_MAGNETIC_FIELD,TYPE_ORIENTATION)
3.Gyroscope (TYPE_GYROSCOPE, TYPE_ROTATION_VECTOR)
4.Light sensor (TYPE_LIGHT)
5.Proximity (TYPE_PROXIMITY)

 Does TYPE_LINEAR_ACCELERATION uses both Acceleromter and Gyroscope
 hardware at its best?
No. TYPE_ACCELEROMETER reports absolute (raw) acceleration. According
to Android on-line docs, The output of the accelerometer, gravity and
linear-acceleration sensors must obey the following relation:
acceleration = gravity + linear-acceleration

It looks like there is a common misunderstanding of MEMS gyro. It only
measures angular speed and nothing else. So if you do not rotate the
phone gyro output should be 0 even if you are accelerating. In other
words, gyro gives you the changes in orientation when the compass
(TYPE_ORIENTATION)  - the absolute orientation. It seems to be a very
subtle difference but gyro gives better results in a real world due to
less sensitivity to the magnetic fields.


 Also when tested on device ( Nexus S ) linear accelerations found to
 give high values for minor shakes , so assuming this removes gravity
 vector, this was not expected.
Why not? A shake can have large acceleration value, here is an example
I recorded on my phone:
7.1234417,6.033814,3.5140498
while in rest the same device shows:
0.20430522,0.47671217,9.493382

Removing gravity from the acceleration is only one issue.
You also need to take care about noise, orientation and variable
timing.


On Mar 13, 3:03 am, Pritam pritamsha...@gmail.com wrote:
 Could someone help to know which sensor uses which part of phone's
 hardware or in what combination of this on Nexus S in android 2.3 ?

 Following are the sensor events:

 TYPE_ACCELEROMETER

 TYPE_GYROSCOPE

 TYPE_GRAVITY

 TYPE_LINEAR_ACCELERATION

 TYPE_ORIENTATION

 TYPE_ROTATION_VECTOR

 I assume first 2 corresponds to separate hardware (accelerometer and
 gyroscope),

 but how with the other remaining ones ?

 Does TYPE_LINEAR_ACCELERATION uses both Acceleromter and Gyroscope
 hardware at its best?

 I am actually interested in linear aceleration so should I need not
 worry about gyro events, if linear acceleration internally uses gyro
 to give out values ?

 Also when tested on device ( Nexus S ) linear accelerations found to
 give high values for minor shakes , so assuming this removes gravity
 vector, this was not expected.

 Thanks.

-- 
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: getBestProvider returning null?

2011-03-03 Thread ip332
Because there is no provider to match your criteria.
Most likely because both providers don't have POWER_LOW.
You can figure out the exact answer by removing Power constrain from
the criteria and checking the output.

On Mar 3, 8:40 am, Jake Colman col...@ppllc.com wrote:
 I am using the following code to get a list of all available providers,
 so I can see what's out there, and to select the best provider based on
 my criteria.  Why would this code return a list of [network gps] for
 all providers but still return null for best provider?

   ListString all = locationManager.getAllProviders();
   logger.verbose( TAG, All available location providers:  + all.toString() 
 );

   Criteria criteria = new Criteria();
   criteria.setAccuracy( Criteria.ACCURACY_COARSE);
   criteria.setAltitudeRequired( false );
   criteria.setBearingRequired( false );
   criteria.setCostAllowed( true );
   criteria.setPowerRequirement( Criteria.POWER_LOW);

   String provider = locationManager.getBestProvider( criteria, true);
   logger.verbose( TAG, Best location provider:  + provider );

 I am getting this behavior on the emulator but I suspect that this may
 be the root cause of an issue seen by one of my users.

 --
 Jake Colman -- Android Tinkerer

-- 
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: getBestProvider returning null?

2011-03-03 Thread ip332
Well, then the docs or the implementation should be fixed and you are
welcomed to wait when it will be resolved ;)

The concept of getBestProvider assume you have hundreds of providers
but don't know what is the best one.
In the reality there are only 2 providers available on most of the
production level Android devices: network and GPS.
So if you want to make sure your code uses network provider then use
its name directly, for example:
 
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
0, 0, locationListener);
When you prefer to use GPS use LocationManager.GPS_PROVIDER

You don't need to use an API just because someone published it,
especially when it doesn't work as you expect.

On Mar 3, 10:56 am, Jake Colman col...@ppllc.com wrote:
 According to the docs, all These constrains, but for cost, are supposed
 to be relaxed until it can find a provider.  Because, otherwise, how can
 I make sure it only uses network even if gps is available?

  i == ip  ip332 writes:

    i Because there is no provider to match your criteria.  Most likely
    i because both providers don't have POWER_LOW.  You can figure out
    i the exact answer by removing Power constrain from the criteria and
    i checking the output.

    i On Mar 3, 8:40 am, Jake Colman col...@ppllc.com wrote:
     I am using the following code to get a list of all available providers,
     so I can see what's out there, and to select the best provider based on
     my criteria. Why would this code return a list of [network gps] for
     all providers but still return null for best provider?
    
     ListString all = locationManager.getAllProviders();
     logger.verbose( TAG, All available location providers:  +
     all.toString() );
    
     Criteria criteria = new Criteria();
     criteria.setAccuracy( Criteria.ACCURACY_COARSE);
     criteria.setAltitudeRequired( false );
     criteria.setBearingRequired( false );
     criteria.setCostAllowed( true );
     criteria.setPowerRequirement( Criteria.POWER_LOW);
    
     String provider = locationManager.getBestProvider( criteria, true);
     logger.verbose( TAG, Best location provider:  + provider );
    
     I am getting this behavior on the emulator but I suspect that this may
     be the root cause of an issue seen by one of my users.
    
     --
     Jake Colman -- Android Tinkerer

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

 --
 Jake Colman -- Android Tinkerer

-- 
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: Gingerbread BroadcastReceiver Issue

2011-03-01 Thread ip332
Jake,

Regarding onStartCommand isn't called after restart.
This is more like a terminology problem: when Android restarts the
service it actually recreates i.e. calls onCreate() method only.
onStartCommand() is not called because nobody requested this service
directly  (e.g. no other process issues callService())

Do your initialization inside onCreate() but keep return START_STICKY
in the onStartCommand().

BTW: you don't need to wait for an hour to recreate the kill/create
scenario: use DDMS to manually kill your service.

Good luck
Igor

-- 
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: logic used by google for displaying map in Android

2011-02-03 Thread ip332
Google does not render maps on the device but gets the bitmaps from
the server.

Honestly speaking, I don't see any reason to do your own map
application unless you are going to make a turn-by-turn navigation.
But navigation is a very complicated task you cannot handle alone,
especially when you have no idea about what are you doing.
You better to do a search on Google Android offline maps and you
will find maps applications as well as navigation solutions and some
open projects too.


On Feb 2, 10:42 pm, sajjoo m.sijj...@gmail.com wrote:
 hi guys,
      i am developing a map application and i have binary map files in
 which i have to read data and make the map tiles and display them on
 canvas. and for displaying the map i am using ImageView Class which
 extends the View class.
 i have large bitmaps which takes alot of memory and my movement of map
 is also too slow.
 so if any one who knows what mechanism or logic has used by google
 team when developing map application for android.
 i,ll be really thankful if anybody can help me about this matter.

 thanks alot.

-- 
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: High sensor usage in stand by

2011-01-27 Thread ip332
Did you check CPU usage using adb shell top ?

On Jan 27, 2:42 am, Alex Munteanu alex.munte...@gmail.com wrote:
 Similar 
 to:http://groups.google.com/group/android-developers/browse_thread/threa...http://groups.google.com/group/android-developers/browse_thread/threa...http://groups.google.com/group/android-developers/browse_thread/threa...

 Please help

 On Jan 27, 11:12 am, Alex Munteanu alex.munte...@gmail.com wrote:







  I'm struggling to find the root cause of a problem that occurs
  apparently randomly in my application. I have a listener registered
  for SENSOR.TYPE_ORIENTATION in my service and on Screen OFF broadcast
  I unregister the listener, and on Screen ON a register it again. From
  time to time, after phone reboot, or maybe unplug, while the most of
  the time the phone is in stand by I get a high sensor usage in phone
  information (along with high battery use associated with my app...) In
  logcat I find lines like this just before Screen OFF :

  01-26 18:02:52.891 E/SensorManager(13487): unregisterListener:
  alex.munteanu.SimpleService$2@48790020 MS-3C Orientation Sensor

  These are some kind of errors that shows that the Listener could not
  be unregistered ? If yes, why and what can I do ?

-- 
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: High sensor usage in stand by

2011-01-27 Thread ip332
D-le Alex, you should learn to read between the lines :)

Here is a snapshot from a phone I had once:
  PID CPU% S  #THR VSS RSS PCY UID  Name
2383  40% S 5   6340K760K  fg compass  /system/bin/some
sensor server
3004  18% S15 240340K  31352K  fg app_90   gpsstatus app from the
market
2941  16% R 9 224140K  22656K  bg app_87   my_top_secret_app_:)
2465  10% S64 336464K  62780K  fg system   system_server
3033   1% R 1844K412K  fg root top

As you can see the system process eats 40% of the CPU which is way too
much for sensor reading task.
Now, I'm not sure if it was a production phone or a development device
with root access - this is why the phone name is not disclosed.
But it is an example of how bad the low level sensors stuff could be
implemented. Most likely they poll data from the port instead of
waiting for an event. I did sensors porting once and pretty much sure
this task should not take such large amount of CPU.

Now,  back to your case. List the top 10 CPU-eating processes and see
if you have similar picture to the one above.
If yes, then accept this as a feature of the phone and check on
another one ;)

On Jan 27, 8:38 am, Alex Munteanu alex.munte...@gmail.com wrote:
 Yes, is not there.

 On Jan 27, 6:23 pm, ip332 iprile...@gmail.com wrote:







  Did you check CPU usage using adb shell top ?

  On Jan 27, 2:42 am, Alex Munteanu alex.munte...@gmail.com wrote:

   Similar 
   to:http://groups.google.com/group/android-developers/browse_thread/threa..

   Please help

   On Jan 27, 11:12 am, Alex Munteanu alex.munte...@gmail.com wrote:

I'm struggling to find the root cause of a problem that occurs
apparently randomly in my application. I have a listener registered
for SENSOR.TYPE_ORIENTATION in my service and on Screen OFF broadcast
I unregister the listener, and on Screen ON a register it again. From
time to time, after phone reboot, or maybe unplug, while the most of
the time the phone is in stand by I get a high sensor usage in phone
information (along with high battery use associated with my app...) In
logcat I find lines like this just before Screen OFF :

01-26 18:02:52.891 E/SensorManager(13487): unregisterListener:
alex.munteanu.SimpleService$2@48790020 MS-3C Orientation Sensor

These are some kind of errors that shows that the Listener could not
be unregistered ? If yes, why and what can I do ?- Hide quoted text -

  - Show quoted text -

-- 
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: Inyect Assistance data to the GPS

2011-01-24 Thread ip332
 Is the
 any way to access the driver or to interact in low level with the A-
 GPS chip of the android device? of course, assuming that the device
 has A-GPS support.
There is no low level interaction from the application level. You
can make your own GPS library but this is not an application
development but rather porting task.
On the other side, if the device has A-GPS support then all necessary
SW support is already there. No phone manufacturer would miss the
opportunity to improve time-too-first-fix (TTFF) which is one of the
most critical parameters in the GPS world.



-- 
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: Having issues with one type of phone.

2011-01-24 Thread ip332
If you are using sensors then check this.

There is a feature specific for Motorola phones: Sensor subsystem
doesn't report SensorEvent unless the values have been changed since
the previous call.

Let's say you are using the following code:
 mSensorManager.registerListener(this, mLightSensor,
SensorManager.SENSOR_DELAY_NORMAL)
If you expect to get roughly 5 updates per second then you are wrong:
you will get update only when driver decides so - it could be in 10
seconds or 30 minutes. Different sensors have different noise level
therefore it is hard to notice on every Sensor on all Motorola phone.
I found it on Milestone (aka Droid) then reproduced it on Motorola
Backflip. Filed a bug but didn't get any feedback.
Someone at Motorola should be very proud of this improvement ;)

On Jan 24, 2:26 pm, darrinps darri...@gmail.com wrote:
 I have an app on the market. Everyone I have had try it (half dozen
 folks or so) likes the thing and it works well, but one type of
 Android based phone seems to have major issues with it.

 In specific, Droids!  The app plays Ogg Vorbis (ogg) sound files and
 displays a white screen at varying intensities (it's a night light
 app).

 Does anyone have a clue as to why Droids act differently than all
 others (I've hit a wide variety of other phones and they all work
 fine)?

 Also as a side note, wouldn't it be GREAT if Google would have a bank
 of phones one could install their application on for testing? We could
 pay a nominal fee, sign up, do our testing, and then let the next one
 hit the phone farm.

 I really hate having bugs that customers have to discover that I don't
 have a good way to solve like this.

-- 
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: WakeLock/Services and sleep

2011-01-24 Thread ip332
When I start Google maps application the screen goes dark after a
certain timeout (when powered from Battery).
There is a possibility to setup screen always on option in case of
external power but it is from a different area.


On Jan 24, 5:33 pm, mikeee mike.engelh...@gmail.com wrote:
 So you're saying Google Navigation *doesn't* use a wakelock and
 continually receive gps updates or that it's somehow an evil
 application because it uses the battery quickly?

 On Jan 24, 5:24 pm, Mark Murphy mmur...@commonsware.com wrote:







  On Fri, Jan 21, 2011 at 8:11 AM, mikeee mike.engelh...@gmail.com wrote:
   I've got an app that starts a service in order to receive location
   updates from the LocationManager.    The use case is the service needs
   to be running all the time and as such it acquires a
   PowerManager.PARTIAL_WAKE_LOCK in the onCreate() of the Service.

  This sounds evil from the standpoint of battery life, if nothing else.

   But it seems from testing on several different phones and user
   feedback that the Service is still being put to sleep as the location
   notifications will stop if the application isn't in the foreground.

  Android does not put applications to sleep. In your case, Android is
  probably terminating your service for being everlasting and using a
  perpetual WakeLock.

   This effectively renders the app ineffective for the task at hand.
   I've read posts about using an Alarm to simulate a pseudo cron job but
   I don't really need to be woken up in order to do a task, the app
   needs to run code based on the location manager calling
   onLocationChanged the service that the users position has changed.

  You can experiment with my LocationPoller, which is designed for your 
  scenario:

 https://github.com/commonsguy/cwac-locpoll

   yet the fact that it
   effectively stops running in some cases is causing problems for the
   users.

  That is because you cannot write everlasting services. Please use
  AlarmManager and something (LocationPoller or your own design) to
  write so you do not have a service and WakeLock in memory all of the
  time.

  --
  Mark Murphy (a Commons 
  Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

  Android Training in London:http://bit.ly/smand1andhttp://bit.ly/smand2

-- 
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: Performance issue with mapview when using large number of items

2011-01-22 Thread ip332
The task is quite common in map drawing applications and the solution
is also common:
1. Create a spatial index - two-dimensional matrix where each item
represent a cell on the screen. The number of cells/rows could be be
calculated from screen/icon proportions. However the size of this
index should be in longitude/latitude units (it should be scale
independent - see below)
2. Only items from this index are shown on the map and only one icon
can be shown on in a cell (you can have an icon which indicates
multiple items per cell)
3. Number of cells is always the same and it much less than 7000
original objects.
4. Each time you change the scale of the map you clear this matrix and
go through source objects and put an object into a cell if it is empty
and objects lat/long belong to it. With 7000 items it should be fast
enough but when you will have millions of them you may have two
indices and use old index while a new one is being calculated
asynchronously. This is why index must be in lat/long units, not
screen pixels.
5. While the map is moving (finger is on the map) you don't need to
update the matrix, only when the moving is complete. It also requires
the index being stored in lat/long.

Such approach gives you flexibility (any scale, any number of objects)
while the drawing complexity depends on the size of the matrix only.

BTW: I also found overlay more efficient than itemized overlay.

On Jan 21, 10:24 pm, Stephan Wiesner testexpe...@googlemail.com
wrote:
 Thanks.
 My current solution is still that I only display markers in a certain
 radius of the center. That works fine, as the markers are peaks/cabins
 in the swiss alps and the user knows where the peaks are anyway.
 If I want to expand my app, though, I need a solution that scales. By
 now I have found several Javasript APIs, that handle this problem in a
 way similiar to what you suggested: by clustering markers.
 e.g.:http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerc...

 I haven't found the time to solve that yet, as it is not pressing at
 the moment. But I will probably define areas (e.g. Berner Oberland,
 Wallis, Tessin) and countries and cluster the markers located there.

 Stephan

 ---
 Interessiert an Android?http://android-schweiz.blogspot.com/
 Whant to learn German?http://german-podcast.blogspot.com

 On 21 Jan., 17:31, Brill Pappin br...@pappin.ca wrote:







  We had an issue like that in an experimental app we never released.

  What worked for us was that we merged points that were overlapping on the
  display depending on the magnification.

  The further in you go, the more those merge point break out, which keeps the
  number of points to a manageable level for the developer and a usable number
  for the user.

  You will need to create a custom point though so that it looks right and its
  clear that points are merged.

  - Brill Pappin

-- 
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: Inyect Assistance data to the GPS

2011-01-20 Thread ip332
 I wonder whether it is possible to send NMEA sentences to the GPS (for
 an A-GPS purpose)?
No, there is no API on the application level.

Or is there any other way to provide/inject
 assistance data to the A-GPS chip?
Assistance data support is part of the GPS library implementation and
it belongs to the HAL in the Android SW stack.
That means two things: not every Android phone has assistance data
support and that you can do this as part of the porting efforts which
is a completely different scale of task.

If you have an external A-GPS receiver (USB, Bluetooth) you can use so
called mock location provider - create your own provider, utilize
TCP/IP to exchange data with your server, use Android's location
providers, etc.  Looks like a perfect approach for any experimental
thing.

On Jan 19, 4:49 am, dep aideuna...@hotmail.com wrote:
 Dear All,

 I’m trying to develop an experimental non-cellular A-GPS system
 composed by an A-GPS server (recollects assistance data and provides
 it when needed through IP) and a A-GPS receiver (ask for the
 assistance data to the A-GPS server). I would like to use an Android
 device for the receiver but I don’t know if it is possible. As I have
 read it is possible to read NMEA sentences (GPSStatus.NMEAListener)
 and to read the position, etc. provided by the GPS device inside the
 Android device.
 I wonder whether it is possible to send NMEA sentences to the GPS (for
 an A-GPS purpose)? Or is there any other way to provide/inject
 assistance data to the A-GPS chip?

 Thank you for your help

-- 
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: Accelerometer and the samplin rate

2011-01-14 Thread ip332
First of all it all device dependent because SENSOR_DELAY_FASTEST has
value 0ms in Android git but 10ms - Samsung Galaxy S.
Using 0ms should result in close to 100% CPU usage so some sensors
drivers have internal logic to prevent such case and add some delay
inside.

On the other side sampling rate is the frequency of measurements
when it seems like you are trying to check how often do you get
SensorEvent.
You should use timestamps inside sensor event if you are interested in
the stability of the sampling rate.
With respect to the unstable rate you get updates from the
SensorManager - this is not a bug, but a feature (explicitly described
in the SensorManager documentation).


On Jan 13, 12:35 am, outi outi1...@googlemail.com wrote:
 Hello,

 does anybody know, why the sensor sampling rate is fluctuating between
 85 and 115 Hertz [Hz] ?
 I tested my accleretation sensor app up to 60 seconds. And I
 calculated the mean sampling rate. In any continous I get an another
 mean sampling rate...

 I'm using the SENSOR_DELAY_FASTET constant:

 sensorManager.registerListener(accelerationListener, sensor,
 SensorManager.SENSOR_DELAY_FASTEST);

 Thank you for your replies!

-- 
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: Anyone know how to calculate speed WITHOUT GPS?

2011-01-12 Thread ip332
You can get location from NETWORK_PROVIDER which can be calculated
from cell towers or WiFi AP.
The first one works almost always but the accuracy is not good
therefore you may get the same location for quite a long time.
All you need to do is to replace GPS_PROVIDER with NETWORK_PROVIDER.

On Jan 11, 8:13 pm, darrinps darri...@gmail.com wrote:
 All the examples I see use GPS, and I have that working just fine but
 I've noticed that every time I'm in a car, that unless the phone is
 close to a window or the windshield the GPS does not work so...

 I thought that there should be a way using course grained location
 between cell towers. Does anyone know if this is possible and if so
 might know where I could find some sample code please?

 Thanks!

 Darrin

-- 
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: LocationManager speed

2011-01-01 Thread ip332
IMHO hasSpeed() is an attribute of the LocationProvider, not the
LocationManager and most likely the GPS_PROVIDER doesn't have speed in
case of emulator.
In other words, speed is an optional attribute not every
LocationProvider has.
I would assume that any real GPS_PROVIDER has it but not
NETWORK_PROVIDER.

On Jan 1, 9:00 pm, darrinps darri...@gmail.com wrote:
 I have a KML file that I feed to the emulator through the DDMS
 emulator control. The latitude and longitude values come through just
 fine, but the thing never has any speed (doing a
 LocationManager.hasSpeed() is always false as is getSpeed() always
 0.0).

 Is there some sort of trick you have to use to get the emulator to
 recognize speed?

 Note that I added a method to calculate the speed based on the math
 involved between the last lat/long coordinate and the current one
 along with the change in time in between the two readings, but I
 THOUGHT this wouldn't need to be done and that I should be able to
 rely on LocationManager.hasSpeed and getSpeed in the real world.

-- 
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: Does Android's GPS location provider do a built-in optimization?

2010-12-29 Thread ip332
If you request updates from the NETWORK_PROVIDER you will get location
from cell towers or WiFi.
If you use GPS_PROVIDER then the GPS will be turned on and you will
get a GPS location after some time.
This some time depends on many factors and the time of the last fix,
first of all.

On Dec 29, 12:47 pm, mohammad shankayi mohd...@gmail.com wrote:
 dianne is right but this ability is only in A-gps devices and as we know all
 android devices has the ability of positioning with cell towers :)
 sincerely
 mohammad shankayi







 On Wed, Dec 29, 2010 at 12:23, Dianne Hackborn hack...@android.com wrote:
  That doesn't really make sense.  When you ask for location, you will
  specify how accurate you want the data to be.  If you ask for GPS accuracy,
  it will start using that (if it hasn't already).  You keep the request open,
  so it continuously looks for satellites and tracks movement.  Each update it
  gives you includes the accuracy of the position, which is based on the
  source of the data (network, GPS, etc), and for GPS the number of
  satellites.

  Often when you first ask for GPS data, there will be no GPS fix at all, but
  you will still be able to get some data based on cell towers.  The accuracy
  information tells you how much you can infer from each report you get.  But
  this is not a one-shot request -- as long as you have asked for position
  reports, it will continually monitor the location as accurately as it can.

  There is of course the newer API to get the last location, and of course
  that is what it says -- the last reported location, whatever that was,
  without use GPS or cell towers to try to determine the current location.

  On Wed, Dec 29, 2010 at 10:59 AM, t tomers...@gmail.com wrote:

  how accurate is the data from Android's GPS location provider?

  does the device always try to seek a satellite, or does it sometimes
  return an optimization of the past locations without querying the
  satellites?

  if this question is device-specific, i'm asking about HTC Hero, HTC
  Desire and Google Nexus One.

  thanks

  --
  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.comandroid-developers%2Bunsubs
   cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

  --
  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.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
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: network LocationProvider

2010-12-29 Thread ip332
If the WiFi service is turned off the you will get position from the
cell tower.
If you could turn off the cell service and keep WiFi on then you get
position from WiFi (however I don't think you can turn off
phone service easily)
But you can use the location accuracy to differentiate between WiFi
and  cell-tower based location
WiFi will give you position accuracy around 50m, cell tower - more
than hundred (from my experience - 200-300m)


On Dec 29, 8:20 am, Dan dan.schm...@gmail.com wrote:
 I have a request to distinguish location sources from the network
 LocationProvider (is it cell tower based, or ip address based).

 Is there a safe rule of thumb proxy I can use to determine this
 e.g. if the phone has a cell signal it uses the cell tower because
 that is more accurate, otherwise it uses the network?

-- 
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 create irregular polygon and handle events within its boundary

2010-12-28 Thread ip332
Processing a click in side a polygon can be difficult task.
There is another solution based on a bitmap where each clickable shape
has its own color.
I have described it in another thread, named Overlay to make parts of
image clickable
Let me know if something is not clear.

On Dec 27, 11:51 am, Achie krishna.acha...@gmail.com wrote:
 How can we create polygons with shapes other than the normal regular
 rectangle/circle etc? I need to create a image with boundaries and let
 users click within the image. Then I need to highlight the image.

 I also need to highlight the image only when the user clicks within
 the boundaries of the shape.
 How can I do this in android?

 Thank you.

-- 
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: SQLite Encryption

2010-12-20 Thread ip332
There is also another opportunity: to use a standard encryption
(javax.crypto.spec.DESKeySpec for example) to encode only some
critical fields in SQLlite table and leave the tables, indexes and
other non-critical fields open.
In this case the critical fields should be encoded and stored as blobs
which should be decoded after reading.
Of course there are several issues to address (keys management,
reverse engineering) but overall it seems to be less complicated than
building your own SQL DB engine (SQLCipher) in native code.

On Dec 20, 10:47 am, DanH danhi...@ieee.org wrote:
 Yeah, that's basically it.  Once you open the DB and set the key the
 DB behaves just like any other SQLite DB.  No extra steps are required
 beyond setting the key.  (Well, except for the minor detail of
 customizing, compiling. building, installing, and debugging your
 SQLCipher port.)

 On Dec 20, 3:52 am, Marco Oreste Migliori mo.migli...@gmail.com
 wrote:







  Thx guys,

  I got SQLCipehr but I'm wondering if to add a key it's enough!
  I mean, let's say I have to create a new encrypted db, the following would
  be the steps needed using SQLCipher  NDK:

  1. Compiling and configuring SQLCipher to add it in my code using NDK.

  2. *Create the db using the standard SQLite fuctions.*

  3. Add a key using the SQLCipher functions.

  Now let's suppose I need to read the db created and encrypted before, I
  should do the following actions:

  1. Open the db using the standard SQLite opening function.
  2. *Use the SQLCipher key function to get access*
  3. Perform the reading
  4. Close the db using the standard SQLite closing function.

  What I want to say is:  is it enough to use the SQLCipher key function just
  in those steps? (I mean the underlined ones)

  Maybe I did not understand the right way to use SQLCipher.

  Thanks in advance,

  Marco.

  On Sun, Dec 19, 2010 at 5:18 AM, DanH danhi...@ieee.org wrote:
   The problem with SQLCipher, of course, is that you need to compile the
   whole C SQLite implementation and embed it in the phone as native
   code.  Doable, but not for the faint of heart.

   But it is certainly the most secure and complete approach to data
   encryption on a phone.

   On Dec 18, 8:10 pm, gjs garyjamessi...@gmail.com wrote:
Hi,

   http://sqlcipher.net/

Regards

On Dec 18, 3:12 am, Marco Oreste Migliori mo.migli...@gmail.com
wrote:

 Hi guys,

 I'm new in Android world, I'm developing  an application which needs
 sensitive data stored in a SQLite db.
 I need to encrypt data but using SQLite that is not possible.

 Is there anyone able to help me?

 Marco

 --

   --
   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.comandroid-developers%2Bunsubs
cr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

  --

-- 
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: Illegal continuation byte in NewStringUTF

2010-12-16 Thread ip332
There is nothing strange.
You have a C string, something like that:
char* fileName = Dracula Der Pfähler.mp3
When you typed this text it was converted into 8-bit code (single
byte, ISO encoding).
So there is nothing strange that NewStringUTF() complains about
illegal continuation byte because fileName is not UTF8 encoded
string.
You need convert this string into UTF8 (aka multibyte) first, then
call NewStringUTF().


On Dec 16, 9:46 am, Luca Carlon carlon.l...@gmail.com wrote:
 Hi! I'm trying to create a jstring using NewStringUTF but I
 experienced a strange issue when the C string passed to the function
 contains characters not ASCII (i.e. accented characters). This is what
 I get:

 01-01 02:56:41.719: WARN/(1738): Creating the jstring for Dracula Der
 Pfähler.mp3.
 01-01 02:56:41.719: WARN/dalvikvm(1738): JNI WARNING: illegal
 continuation byte 0x68
 01-01 02:56:41.719: WARN/dalvikvm(1738):              string: 'Dracula
 Der Pfähler.mp3'
 01-01 02:56:41.719: WARN/dalvikvm(1738):              in method_name
 (NewStringUTF)

 where the first line is created using the char* and the android log
 functions. This is the piece of code:

 jstring pathStr;
 LOGW(Creating the jstring for %s., fileName);
 if ((pathStr = mEnv-NewStringUTF(fileName)) == NULL) {
    LOGE(Failed NewStringUTF.);
    return false;}

 LOGW(The jstring has been created...);

 Any idea why this is happening?
 Thanks!

-- 
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 location

2010-12-16 Thread ip332
0.1 degree is close to 1 meter on equator so you can keep 6 digits
after decimal point and drop the rest without any difference for
practical purpose.

On Dec 16, 3:10 am, osa osama...@gmail.com wrote:
 Hello.
 I try to use LocationManager  for reading GPS coords and transfer to
 my server
 But I have a problem :
 - What I have:
 49,43930581
 32,07179546
 - It the LocationManager I see coord like
 49.439305
 32.0717945
 So I have problem with accuracy I am not sure is it problem with Java
 double or something else
 Plz help.

-- 
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: LocationListener's onLocationChanged() is not called (geo fix)

2010-12-15 Thread ip332
Typical GPS position accuracy is 3-10 meters in average.
A position from NETWORK_PROVIDER can be derived from the WiFi or
cellular networks which obviously have different accuracy.
WiFi position accuracy: 20-70
Cell position: 100-500

You can get some idea about these values by looking at your position
on Google map and turning on/off GPS and WiFi.
The circle around this position shows error estimation.

On Dec 14, 11:55 pm, Danny Schimke danny.schi...@googlemail.com
wrote:
 Ah ok, I understand. So I'll use GPS indtead of network provider while I am
 developing the application. @ip332 Thank you very much! Maybe another
 question: how much differs the accurace of the gps to the network provider
 (maybe about in meters)?

 Thanks a lot!

 -Danny Schimke

 2010/12/14 ip332 iprile...@gmail.com







  You can't simulate position changes in the network on emulator unless
  you use a laptop with WiFi connection. But walking around with laptop
  in hands is not really a simulation either ;)

  I use GPS provider instead of Network for debugging.

  On Dec 14, 8:32 am, Danny Schimke danny.schi...@googlemail.com
  wrote:
   How can I simulate changes in the network location and why does it not
   changed, but GPS changed?

   THX,
   -Danny Schimke

   2010/12/14 ip332 iprile...@gmail.com

Because there were no changes in the network location.

On Dec 14, 7:40 am, Danny Schimke danny.schi...@googlemail.com
wrote:
 Hi,

 I changed LocationManager.NETWORK_PROVIDER to
LocationManager.GPS_PROVIDER
 and now onLocationChanged() is called. But I cant explain why?! I
configured
 the proxy correctly and I am able to call websites from browser and
  load
 Google Map in my application.

 Anyone know why it does not work? Permission is set in
  AndroidManifest,
so
 this can't be the issue.

 Thanks a lot!
 -Danny Schimke

 2010/12/14 Danny Schimke danny.schi...@googlemail.com

  Hi,

  I have a Service that will run in Background even if the
  application is
  closed. I started the service and I can see it in the running
services
  section under application settings. I am using *geo fix* to tell
  the
  emulator location changes. Every time I change the location there
  is an
OK
  e.g.: geo fix -37.0625 95.67706*OK *but onLocationChanged() is
  never
  called. The same if I tried using DDMS view in eclipse to update
location. I
  checked the system location preferences and network location is
  enabled
(I
  only need network application changes, no GPS). Permissions are set
  in
  AndroidManifest.xml.

  I can not figure out why it does not work... here is some code:

  public class MyService extends Service {

  private static final String TAG = MyService;
   private LocationManager locationMgr;
  private LocationListener locListener;

  // This method is called
  @Override
  public void onCreate() {
   super.onCreate();
  Log.d(TAG, onCreate);
  locationMgr = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
   locListener = new LocationListener() {
  // ...
  // other methods here
   // ...
  @Override
  public void onLocationChanged(Location location) {
   // never called
  Log.d(TAG, onLocationChanged);
  // some code here...
   }
  };

  locationMgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0,
0,
  locListener);
   }

  // This method is called
  @Override
   public void onStart(Intent intent, int startId) {
  super.onStart(intent, startId);
   Log.d(TAG, onStart);
  Toast.makeText(getApplicationContext(), Service started
  successfully.
  Listening in Background for location changes.,
Toast.LENGTH_LONG).show();
   }

  I started the service from an activity:

  serviceIntent = new Intent(this, MyService.class);
  ...
  startService(serviceIntent);

  Does anybody knows why it does not work? Hope someone can help.
  Thank you very much in advance!

  -Danny Schimke

--
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.comandroid-developers%2Bunsubs
 cr...@googlegroups.comandroid-developers%2Bunsubs
  cr...@googlegroups.com
For more options, visit this group at
   http://groups.google.com/group/android-developers?hl=en

  --
  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.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options

[android-developers] Re: LocationListener's onLocationChanged() is not called (geo fix)

2010-12-14 Thread ip332
Because there were no changes in the network location.

On Dec 14, 7:40 am, Danny Schimke danny.schi...@googlemail.com
wrote:
 Hi,

 I changed LocationManager.NETWORK_PROVIDER to LocationManager.GPS_PROVIDER
 and now onLocationChanged() is called. But I cant explain why?! I configured
 the proxy correctly and I am able to call websites from browser and load
 Google Map in my application.

 Anyone know why it does not work? Permission is set in AndroidManifest, so
 this can't be the issue.

 Thanks a lot!
 -Danny Schimke

 2010/12/14 Danny Schimke danny.schi...@googlemail.com







  Hi,

  I have a Service that will run in Background even if the application is
  closed. I started the service and I can see it in the running services
  section under application settings. I am using *geo fix* to tell the
  emulator location changes. Every time I change the location there is an OK
  e.g.: geo fix -37.0625 95.67706*OK *but onLocationChanged() is never
  called. The same if I tried using DDMS view in eclipse to update location. I
  checked the system location preferences and network location is enabled (I
  only need network application changes, no GPS). Permissions are set in
  AndroidManifest.xml.

  I can not figure out why it does not work... here is some code:

  public class MyService extends Service {

  private static final String TAG = MyService;
   private LocationManager locationMgr;
  private LocationListener locListener;

  // This method is called
  @Override
  public void onCreate() {
   super.onCreate();
  Log.d(TAG, onCreate);
  locationMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
   locListener = new LocationListener() {
  // ...
  // other methods here
   // ...
  @Override
  public void onLocationChanged(Location location) {
   // never called
  Log.d(TAG, onLocationChanged);
  // some code here...
   }
  };
  locationMgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
  locListener);
   }

  // This method is called
  @Override
   public void onStart(Intent intent, int startId) {
  super.onStart(intent, startId);
   Log.d(TAG, onStart);
  Toast.makeText(getApplicationContext(), Service started successfully.
  Listening in Background for location changes., Toast.LENGTH_LONG).show();
   }

  I started the service from an activity:

  serviceIntent = new Intent(this, MyService.class);
  ...
  startService(serviceIntent);

  Does anybody knows why it does not work? Hope someone can help.
  Thank you very much in advance!

  -Danny Schimke

-- 
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: LocationListener's onLocationChanged() is not called (geo fix)

2010-12-14 Thread ip332
You can't simulate position changes in the network on emulator unless
you use a laptop with WiFi connection. But walking around with laptop
in hands is not really a simulation either ;)

I use GPS provider instead of Network for debugging.

On Dec 14, 8:32 am, Danny Schimke danny.schi...@googlemail.com
wrote:
 How can I simulate changes in the network location and why does it not
 changed, but GPS changed?

 THX,
 -Danny Schimke

 2010/12/14 ip332 iprile...@gmail.com







  Because there were no changes in the network location.

  On Dec 14, 7:40 am, Danny Schimke danny.schi...@googlemail.com
  wrote:
   Hi,

   I changed LocationManager.NETWORK_PROVIDER to
  LocationManager.GPS_PROVIDER
   and now onLocationChanged() is called. But I cant explain why?! I
  configured
   the proxy correctly and I am able to call websites from browser and load
   Google Map in my application.

   Anyone know why it does not work? Permission is set in AndroidManifest,
  so
   this can't be the issue.

   Thanks a lot!
   -Danny Schimke

   2010/12/14 Danny Schimke danny.schi...@googlemail.com

Hi,

I have a Service that will run in Background even if the application is
closed. I started the service and I can see it in the running
  services
section under application settings. I am using *geo fix* to tell the
emulator location changes. Every time I change the location there is an
  OK
e.g.: geo fix -37.0625 95.67706*OK *but onLocationChanged() is never
called. The same if I tried using DDMS view in eclipse to update
  location. I
checked the system location preferences and network location is enabled
  (I
only need network application changes, no GPS). Permissions are set in
AndroidManifest.xml.

I can not figure out why it does not work... here is some code:

public class MyService extends Service {

private static final String TAG = MyService;
 private LocationManager locationMgr;
private LocationListener locListener;

// This method is called
@Override
public void onCreate() {
 super.onCreate();
Log.d(TAG, onCreate);
locationMgr = (LocationManager)
  getSystemService(Context.LOCATION_SERVICE);
 locListener = new LocationListener() {
// ...
// other methods here
 // ...
@Override
public void onLocationChanged(Location location) {
 // never called
Log.d(TAG, onLocationChanged);
// some code here...
 }
};
locationMgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0,
  0,
locListener);
 }

// This method is called
@Override
 public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
 Log.d(TAG, onStart);
Toast.makeText(getApplicationContext(), Service started successfully.
Listening in Background for location changes.,
  Toast.LENGTH_LONG).show();
 }

I started the service from an activity:

serviceIntent = new Intent(this, MyService.class);
...
startService(serviceIntent);

Does anybody knows why it does not work? Hope someone can help.
Thank you very much in advance!

-Danny Schimke

  --
  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.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
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: GPS

2010-12-10 Thread ip332
It will be turned on when you request location updates (if it is
enabled in the Location/GPS settings)

On Dec 10, 4:47 pm, Hendrik Greving fourhend...@gmail.com wrote:
 I know how to read the GPS status etc. but how do I turn the chip on/off? 
 There is nothing in LocationManager/Provider or GpsStatus or Satellite

-- 
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: GPS

2010-12-10 Thread ip332
Do what? Turn GPS on upon clicking on GPS in the Settings/location?
If you come from the in-car navigation world then this scenario looks
weird.
However battery life is one of the most critical parameters for a
mobile phone therefore it makes sense to turn hardware on only when
there is a client to use it.

On Dec 10, 4:59 pm, Hendrik Greving fourhend...@gmail.com wrote:
 Eww. I just read about this. I guess this is a FAQ, but why can the Power 
 Control Widget do this?







   - Original Message -
   From: TreKing
   To: android-developers@googlegroups.com
   Sent: Friday, December 10, 2010 4:47 PM
   Subject: Re: [android-developers] GPS

   On Fri, Dec 10, 2010 at 6:47 PM, Hendrik Greving fourhend...@gmail.com 
 wrote:

     I know how to read the GPS status etc. but how do I turn the chip on/off?

   You can't. You can bring up the settings screen to let the user turn it on 
 or off, if they want.

   --- 
 --
   TreKing - Chicago transit tracking app for Android-powered devices

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

-- 
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: JPEG Image has a map

2010-12-08 Thread ip332
Here is the actual code to show an image on top of the Google map.
Regards
Igor
===
package com.map.overlay;

import java.util.List;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;

public class MyOverlay extends MapActivity {
Bitmap  bmp;// loaded bitmap in memory
GeoPointmin;// top left corner (lat/long)
GeoPointmax;// right bottom corner (lat/long)

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

bmp = BitmapFactory.decodeFile(/sdcard/test.bmp); // load 
bitmap
(can use JPG,PNG,etc.)
min = new GeoPoint(37374000,-121913000);// 
bounding rectangle
max = new GeoPoint(37375000,-121912000);

MapView mapView = (MapView) findViewById(R.id.mapView);
mapView.setSatellite(true); // 
switch to the satellite
view
MapController ctrl = mapView.getController();
int x = (min.getLongitudeE6() + max.getLongitudeE6())/ 2;   
// select
map center
int y = (min.getLatitudeE6() + max.getLatitudeE6())/ 2;
ctrl.setCenter(new GeoPoint(y,x));
ctrl.setZoom(21);   // set 
scale
mapView.setBuiltInZoomControls(true);   // 
enable zoom controls

MapOverlay mapOverlay = new MapOverlay();
ListOverlay listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);

mapView.invalidate();
}

class MapOverlay extends Overlay
{
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean 
shadow,
long when)
{
// convert bitmap's bounding box into pixels
Point top_left = new Point();
mapView.getProjection().toPixels(min, top_left);
Point bottom_right = new Point();
mapView.getProjection().toPixels(max, bottom_right);

// Prepare two rectangles (pixels)
Rect src = new Rect( 0,0,bmp.getWidth() - 1, 
bmp.getHeight() - 1 );
Rect dst = new Rect( top_left.x, bottom_right.y,
bottom_right.x,top_left.y );

// draw bitmap
canvas.drawBitmap( bmp, src, dst, null);
return true;
}
}

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}

}

On Dec 8, 12:32 am, sal suhailb...@gmail.com wrote:
 Thank guys for your suggestion

 @Frank

 What do you mean Mobile CAD, i want just a mark up on the JPEG image
 based on predefined locations , thats it.
 i thot Google Map API would provide me better support of doing markup
 if i am able to convert JPEG image into google map
 do u have any good pointer or reference to application which does mark
 up on image.

 @Igor
 Buddy, i have developed an application to draw a image on MapView ,
 logic wise i know its right
 somewhere i am messing with certain objects which leads to exception .
 so i requested for  sample code  so that i can cross verify

 regards
 Sal

 On Dec 8, 6:04 am, ip332 iprile...@gmail.com wrote:







  Sol,
  No offense, but ability to debug the application (especially when you
  have source code and debugging tools) is one of the most basic things
  any programmer must have.
  Yes, Android make programming looks like a pretty simple and easy
  activity however when you don't understand what are you doing and
  cannot debug the problem - you won't get anything good out of it.
  They say There is no replacement for a displacement about a car
  engine. Same here - you can't ask for a ready-to-use code to get more
  or less acceptable result unless you spent certain amount of time,
  nerves, coffee, etc.
  Nobody get it from the first time. Google it, ask questions but do not
  expect someone to solve your problem.

  Anyway I will try to create a sample app but don't know when I'll have
  time (my current program belongs to the company)

  On Dec 6, 11:54 pm, sal suhailb...@gmail.com wrote:

   thanks for ur concerns,

   @Frank
   I have JPEG sketch of my apartment, getting just geocode of my

[android-developers] Re: JPEG Image has a map

2010-12-07 Thread ip332
Sol,
No offense, but ability to debug the application (especially when you
have source code and debugging tools) is one of the most basic things
any programmer must have.
Yes, Android make programming looks like a pretty simple and easy
activity however when you don't understand what are you doing and
cannot debug the problem - you won't get anything good out of it.
They say There is no replacement for a displacement about a car
engine. Same here - you can't ask for a ready-to-use code to get more
or less acceptable result unless you spent certain amount of time,
nerves, coffee, etc.
Nobody get it from the first time. Google it, ask questions but do not
expect someone to solve your problem.

Anyway I will try to create a sample app but don't know when I'll have
time (my current program belongs to the company)


On Dec 6, 11:54 pm, sal suhailb...@gmail.com wrote:
 thanks for ur concerns,

 @Frank
 I have JPEG sketch of my apartment, getting just geocode of my
 apartment doesnt serve my purpose.
 i want to do location markup on that JPEG image,  i have stored
 location information which i want to mark on the image using android
 API's
 so i want to convert my image as a google map then use android API's
 to mark location on that. let me know if u need more information.

 @Igor
 As i am new to android
 can u give me simple example with main activity illustrating on  how
 to draw JPEG image on MapView with overlays to mark on the co-ordinate
 of the image
 i tried doing it but i am getting NULL exception while using overlays

 rgds
 Sal

 On Dec 6, 6:46 am, ip332 iprile...@gmail.com wrote:







  I used the Overlay class for this purpose.
  Here is the main part of the MyOverlay::Draw() method:
          // convert bitmap's bounding box into pixels
          Point top_left = new Point();
          mapView.getProjection().toPixels(min, top_left);
          Point bottom_right = new Point();
          mapView.getProjection().toPixels(max, bottom_right);
          // Prepare two rectangles (pixels)
          Rect src = new Rect( 0,0,bmp.getWidth() - 1, bmp.getHeight() -
  1 );
          Rect dst = new Rect( top_left.x, bottom_right.y,
  bottom_right.x,top_left.y );
          // draw bitmap
          canvas.drawBitmap( bmp, src, dst, null);
  Since it uses current mapView then zooming and panning are supported
  automatically.
  Obviously you need to know left top (GeoPoint min in the code above)
  and right bottom (GeoPoint max) coordinates for your picture (I used
  Google Earth for this purpose).
  Good luck.
  Igor

  On Dec 5, 6:36 am, suhail ahmed suhailb...@gmail.com wrote:

   Hi,

   I have JPEG, PDF of sketch of my apartment, i want to make it as a google
   map so that i can use Google API's (geocoding, reverse geocoding) on that.

   may i know the solution for the problem

   regards
   Sal

-- 
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: Best approach for LocationPolling service

2010-12-06 Thread ip332
Sorry, I don't understand both statements.
I'm using described postAtTime() method in several cases and none of
them could be called 24/7 service. Obviously it can be implemented
as a service but regardless of mode (app/service) it doesn't consume
the CPU/battery between calls.
Compare this approach with a straightforward request location update
inside onStart() and disable it during onPause() and you should see
the difference.
I don't have time to look into AlarmManager implementation to prove
that it has a similar approach and using AlarmManager gives you
absolutely no advantage in CPU/batter nor RAM.
Of course you can try to kill your process after each 15 minutes
interval  to save RAM which is impossible in my case but honestly
speaking, killing the process is not required by Android and there
were serious reasons for that.
Regards
Igor
On Dec 6, 7:11 am, Mark Murphy mmur...@commonsware.com wrote:
 On Sun, Dec 5, 2010 at 9:38 PM, ip332 iprile...@gmail.com wrote:
   Or should I try to create a kind of service thread that polls every
   (n) minutes and sleeps in between, would that save battery?

  Yes, but it will waste RAM and cause you to be the target of task killers.
  I disagree - it depends on how do you implement actual runner.

  IMHO if you create location listener every X minutes and remove it
  after you got a location update (10-60 seconds) - there is no wasted
  RAM nor battery.

 If you have a Service running 24x7 to accomplish this, yes, you are wasting 
 RAM.

  Also I would implement it using Hanlder.postAtTime() approach
  described 
  athttp://developer.android.com/resources/articles/timed-ui-updates.html

 Which implies a Service running 24x7, which means users will attack
 you with task killers.

 We can do better than this, with AlarmManager, but the work is just a
 bit tricky.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 Android 2.2 Programming Books:http://commonsware.com/books

-- 
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: Overlay to make parts of image clickable

2010-12-06 Thread ip332
Someone sent the following comment directly to me:
 ... if he has a few of this click able images you need more memory
 for your map as it's bitmap if it's not 255 colors it's a big memory
 consumption...
Since the comment is valid here is my answer (also valid ;)
If you have a large screen image with a tiny round button - create a
small bitmap to cover this button only and store it along with
left,top pixel coordinates on the screen. You can have bunch of such
clickable areas if you want to minimize RAM.

There is another cool solution with some restrictions:
Use lower 2-3 bits in the Alpha channel of the visible image to store
the click ID
We need to use ARGB 32 bpp bitmap format so we have 8 bit to store
alpha (transparency)
However, in case of custom GUI the alpha layer usually set to the
completely non-transparent value.
If we add just a few bits of transparency just the end user most
likely won't see the difference.
But you can extract this value for the click point and get the code
from there.
There are two serious limitations:
1. Only a limited number of click ID can be supported otherwise end
user will see some artifacts around the click able areas.
2. The bitmap preparation becomes really tricky because you have to
set alpha level for a certain areas to some exact value.


On Dec 6, 3:08 am, bagelboy greg.do...@gmail.com wrote:
 It just so happens that each area of the image has a specific color,
 so that is an excellent idea, thanks very much for your suggestion.

 On Dec 6, 7:19 am, ip332 iprile...@gmail.com wrote:







  Here is a generic solution for handling any number of arbitrary shaped
  hotspots:
  1) create additional bitmap (same size as what you plan to show on the
  screen) and draw hot areas with a specific color. If you have less
  than 255 hotspots then use 8bpp bitmap with background of color with
  index 0. Draw the first hot spot with desired shape and color it with
  index 1, then the second area - with index 2 and so on. Or you can do
  it with 24bpp bitmap but assign each area a specific RGB combination.
  2) load this bitmap (let's call it control) when your application
  starts up.
  3) on screen click: convert screen coordinates into x,y from the
  origin of your image (which can be larger than the screen)
  4) get pixel color from the control bitmap - if it is  0 then it is a
  hotspot index of code.
  Good luck
  Igor

  On Dec 5, 5:43 am, bagelboy greg.do...@gmail.com wrote:

   I have an image and I want to make parts of it clickable. From my
   research I can see 2 ways to do this:
   1) I could chop the image into pieces and put them into a relative
   layout
   2) I could create a matrix of points that describe the clickable areas
   and use onTouch events to track clicks

   Option 1 has the drawback where you have to make areas square or
   rectangular, plus alignment and scaling are a pain.

   Option 2 can be scaled easier however I'm not sure how to go about
   coding it.

   Am I missing any possibilities? Are there any tools or source code
   that would make it easier?

   -BB

-- 
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: make JPEG image as a google map

2010-12-06 Thread ip332
Check this thread please:
http://groups.google.com/group/android-developers/browse_thread/thread/def19b49f497b21c


On Dec 6, 5:05 am, sal suhailb...@gmail.com wrote:
 Hi,

 I would like to know if there is anyway to make JPEG sketch of my
 building as google map so that i can use google map or earth API's to
 mark the required  location on the map. its somewhat urgent

 regards
 Suhail

-- 
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: Best approach for LocationPolling service

2010-12-05 Thread ip332
  Or should I try to create a kind of service thread that polls every
  (n) minutes and sleeps in between, would that save battery?

 Yes, but it will waste RAM and cause you to be the target of task killers.
I disagree - it depends on how do you implement actual runner.

IMHO if you create location listener every X minutes and remove it
after you got a location update (10-60 seconds) - there is no wasted
RAM nor battery.
I would request updates from both providers (GPS and Network) because
Network location usually available much faster and can be used to
estimate if we need to wait the GPS or not.
Also I would implement it using Hanlder.postAtTime() approach
described at 
http://developer.android.com/resources/articles/timed-ui-updates.html
The Runnable should implement two things:
1. Request location updates and schedule next poll in 30 seconds. This
short interval is needed to check if we got location or not. If we
didn't get location update in 1-2 minutes then it is better to stop
updates and try it later (to preserve the battery).
2. Remove location updates and schedule next poll in 15/30 minutes

Let me know if you need more details.
Regards
Igor

On Dec 5, 1:14 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Sun, Dec 5, 2010 at 4:02 PM, CChange wer...@c-change.eu wrote:
  I am writing a little app, that needs to poll location every n minutes
  (usually every 15 or 30 minutes), do some logic with that information
  and store something into the db. There is a GUI to all that of course,
  but obviously I dont want that to run in the background as well. Just
  the polling and that little logic.

  So my main question in regards to that, how would you write that if
  you wanted to keep bat usage low.

  At first I thought about the

  LocationManager.addProximityAlert(..) method, but then I read that
  that will be polled every 4 minutes which I  dont need. Or does that
  not use additional battery because the phone notifies all listeners
  anyway?

 It will only notify you when the user gets within such-and-so distance
 of a particular point, which does not seem to fit your desired
 functionality.

  Or should I try to create a kind of service thread that polls every
  (n) minutes and sleeps in between, would that save battery?

 Yes, but it will waste RAM and cause you to be the target of task killers.

 The ideal answer is to use AlarmManager, so your service only runs
 when it is actually collecting data. For GPS, though, this is tricky
 -- you do not want the GPS radio on all of the time (big battery
 drain), and there are a lot of edge cases (e.g., user has GPS
 disabled, user is in a large building and cannot get a GPS signal).
 I've been working on a WakefulLocationService that fits your desired
 functionality, but it hasn't been a high priority, so it is still in
 pieces on the lab bench.

 Does anyone have something like this already implemented that they could 
 share?

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 Android App Developer Books:http://commonsware.com/books

-- 
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: JPEG Image has a map

2010-12-05 Thread ip332
I used the Overlay class for this purpose.
Here is the main part of the MyOverlay::Draw() method:
// convert bitmap's bounding box into pixels
Point top_left = new Point();
mapView.getProjection().toPixels(min, top_left);
Point bottom_right = new Point();
mapView.getProjection().toPixels(max, bottom_right);
// Prepare two rectangles (pixels)
Rect src = new Rect( 0,0,bmp.getWidth() - 1, bmp.getHeight() -
1 );
Rect dst = new Rect( top_left.x, bottom_right.y,
bottom_right.x,top_left.y );
// draw bitmap
canvas.drawBitmap( bmp, src, dst, null);
Since it uses current mapView then zooming and panning are supported
automatically.
Obviously you need to know left top (GeoPoint min in the code above)
and right bottom (GeoPoint max) coordinates for your picture (I used
Google Earth for this purpose).
Good luck.
Igor

On Dec 5, 6:36 am, suhail ahmed suhailb...@gmail.com wrote:
 Hi,

 I have JPEG, PDF of sketch of my apartment, i want to make it as a google
 map so that i can use Google API's (geocoding, reverse geocoding) on that.

 may i know the solution for the problem

 regards
 Sal

-- 
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: Overlay to make parts of image clickable

2010-12-05 Thread ip332
Here is a generic solution for handling any number of arbitrary shaped
hotspots:
1) create additional bitmap (same size as what you plan to show on the
screen) and draw hot areas with a specific color. If you have less
than 255 hotspots then use 8bpp bitmap with background of color with
index 0. Draw the first hot spot with desired shape and color it with
index 1, then the second area - with index 2 and so on. Or you can do
it with 24bpp bitmap but assign each area a specific RGB combination.
2) load this bitmap (let's call it control) when your application
starts up.
3) on screen click: convert screen coordinates into x,y from the
origin of your image (which can be larger than the screen)
4) get pixel color from the control bitmap - if it is  0 then it is a
hotspot index of code.
Good luck
Igor

On Dec 5, 5:43 am, bagelboy greg.do...@gmail.com wrote:
 I have an image and I want to make parts of it clickable. From my
 research I can see 2 ways to do this:
 1) I could chop the image into pieces and put them into a relative
 layout
 2) I could create a matrix of points that describe the clickable areas
 and use onTouch events to track clicks

 Option 1 has the drawback where you have to make areas square or
 rectangular, plus alignment and scaling are a pain.

 Option 2 can be scaled easier however I'm not sure how to go about
 coding it.

 Am I missing any possibilities? Are there any tools or source code
 that would make it easier?

 -BB

-- 
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 throwing exception

2010-12-01 Thread ip332
Server is always running at Google.com
Your phone needs a connection to this server in order to draw the map
or to geocode a string.
Without such connection you may see some pieces of map because of
GoogleMaps caching but geocode interface requires direct channel to
the server.


On Nov 30, 6:46 pm, kiran saikiran@gmail.com wrote:
 Can we start Geocoding server through application

 On Dec 1, 3:23 am, TreKing treking...@gmail.com wrote:







  On Tue, Nov 30, 2010 at 3:04 PM, ip332 iprile...@gmail.com wrote:
   As we know Google map is stored on the web therefore you must have 3G, 
   Edge
   or WiFi channels enabled in order to use Geocoding.

  Also, even if you have a perfect connection, the actual geo-coding server
  has to actually be running.

  --- 
  --
  TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
  transit tracking app for Android-powered devices

-- 
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 throwing exception

2010-12-01 Thread ip332
Most likely the servers for maps and geocoding are different,
however the common thing is that both services require connection.
They both use the same network (cellular or WiFi) so if the network is
down none of them will work (except cached map data).
Geocode may fail if you submit wrong address, that is true but the
original question was why is it throwing exception.

On Dec 1, 12:31 pm, TreKing treking...@gmail.com wrote:
 On Wed, Dec 1, 2010 at 12:50 PM, ip332 iprile...@gmail.com wrote:
  Your phone needs a connection to this server in order to draw the map or to
  geocode a string.

 While geocoding and maps are related, they're not the same thing and I
 highly doubt they're backed by the same server. It's entirely possible to
 have full Maps access and have the geocoding fail.

 --- 
 --
 TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
 transit tracking app for Android-powered devices

-- 
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 throwing exception

2010-12-01 Thread ip332
Off-topic, but 2 important cents:
Do you really need to develop it by yourself when several more or less
completed projects are available on the Android market already ?
For example: http://www.mapdroyd.com/ or http://www.andnav.org/
The second one is (or going to be) an open source project.


On Dec 1, 4:22 pm, XiaoXiong Weng ad...@littlebearz.com wrote:
 I recall there was an openmap where you could just download the area you
 need and store it to SD card and then view it from there, this can be
 beneficial to user who does not have internet. I'm trying to develop this
 software but I need a lot more time.
 Progress can be found athttp://android.littlebearz.com/







 -Original Message-
 From: android-developers@googlegroups.com

 [mailto:android-develop...@googlegroups.com] On Behalf Of kiran
 Sent: Tuesday, November 30, 2010 9:47 PM
 To: Android Developers
 Subject: [android-developers] Re: Geocoder throwing exception

 Can we start Geocoding server through application

 On Dec 1, 3:23 am, TreKing treking...@gmail.com wrote:
  On Tue, Nov 30, 2010 at 3:04 PM, ip332 iprile...@gmail.com wrote:
   As we know Google map is stored on the web therefore you must have 3G,
 Edge
   or WiFi channels enabled in order to use Geocoding.

  Also, even if you have a perfect connection, the actual geo-coding server
  has to actually be running.

 ---
 --
  TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
  transit tracking app for Android-powered devices

 --
 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 
 athttp://groups.google.com/group/android-developers?hl=en

-- 
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: LocationListener sometimes not receiving updates from network provider

2010-11-30 Thread ip332
Michael

Here are some suggestions:
1. Additional logging: mCoarseLocationListener details, WiFi status,
cell signal status (may be in those 5% cases users don't have any
signal?)
2. Get details from users about phone models, running applications and
Android versions. Recently I found interesting feature on Motorola
phone: sensors do not report events unless the values have been
changed - this is a violation of the Android API. May be somewhat
similar happens with respect to the network location on some phones.
3. Add listener restart logic after a certain timeout, i.e. if you
didn't get onLocationChanged() after a certain time stop the listener,
create and start it again.
4. Get Android source code and study the LocationManager hierarchy.
Probably the most complicated approach but I would start from here.

Best regards
Igor

On Nov 30, 3:07 am, michael michael.d.peder...@googlemail.com wrote:
 Hi Igor,

 Thanks for your reply, it is much appreciated. Thanks also for
 pointing out the issues with the code I provided. However, this was
 merely a stripped-down outline of what I am doing. The use of
 mCoarseLocationListener is a type from the strip-down process, and I
 agree that the LocationProvider variable is not necessary.

 However, the problem remains that while the code works fine in 95% of
 cases, there are still 5% of cases where I never get a call to
 onLocationChanged. Any suggestions as to why this is the case would
 still be much appreciated.

 Best,
 Michael.

 On Nov 30, 12:29 am, ip332 iprile...@gmail.com wrote:







  Michael,

  According to Android documentation the following call
  locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
  0, 0, this);
  requests updates from WiFi or cellular network which means you should
  get some update (from cell tower) even if WiFi location is not
  available. However, I've seen cases when Google map application failed
  to set map to MyLocation for several minutes while driving on a
  freeway.

  Back to your code. I think you need to replace
  getLastKnownLocation(mCoarseLocationProvider) with
  getLastKnownLocation(LocationManager.NETWORK_PROVIDER) - it is not
  clear where do you get mCoarseLocationProvider.
  Also you don't need to use LocationProvider variable in your code
  fragment:
       public MyLocationListener() {
           mLocMan =
  (LocationManager)getSystemService(Context.LOCATION_SERVICE);

           if
  (mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) !=
  null) {
               mCurrentLocation =
  mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
           }

          
  mLocMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
  this);
       }

  Check the following link which has a lot of useful 
  suggestions:http://developer.android.com/guide/topics/location/obtaining-user-loc...

  Bets regards
  Igor

  On Nov 29, 2:44 pm, michael michael.d.peder...@googlemail.com wrote:

   Let me also add that the location listener does sometimes get calls to
   onProviderEnabled -- this happens after asking the user to enable
   wireless network locations if initially disabled. So I know for sure
   that the listener is registered correctly. It just never gets an
   onLocationChanged call.

   /Michael.

   On Nov 29, 10:10 pm, michael michael.d.peder...@googlemail.com
   wrote:

Hi folks,

I have a location listener running in a foreground service. The
listener registers for wireless network updates in its constructor. In
the majority of cases, location updates are received as expected.

However, log entries from the live app show that for about 5% of my
users, location updates are never received even though wireless
network location is enabled on the phone (I check this through the
LocationManager.isProviderEnabled method). That is, onLocationChanged
is never called, at least not within say 20 minutes of registering the
listener.

Does anybody have any idea why this might be? Are there cases, or
certain geographic areas, where you would not expect wireless
locations to be available?

A stripped-down outline of the location listener code is shown below:

class MyLocationListener extends LocationListener {
    private Location mLocation = null;

    public MyLocationListener() {
        mLocMan = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);

        if (mLocMan.getLastKnownLocation(mCoarseLocationProvider) !=
null) {
            mCurrentLocation =
mLocMan.getLastKnownLocation(mCoarseLocationProvider);
        }

        LocationProvider lp =
mLocMan.getProvider(LocationManager.NETWORK_PROVIDER);
        mLocMan.requestLocationUpdates(lp.getName(), 0, 0, this);
    }

    public void onLocationChanged(Location loc) {
        mLocation = loc;
    }

}

I verify through flurry logs that the network location provider

[android-developers] Re: LocationListener sometimes not receiving updates from network provider

2010-11-30 Thread ip332
One more thing: check how and when do you remove listener.

On Nov 30, 11:52 am, ip332 iprile...@gmail.com wrote:
 Michael

 Here are some suggestions:
 1. Additional logging: mCoarseLocationListener details, WiFi status,
 cell signal status (may be in those 5% cases users don't have any
 signal?)
 2. Get details from users about phone models, running applications and
 Android versions. Recently I found interesting feature on Motorola
 phone: sensors do not report events unless the values have been
 changed - this is a violation of the Android API. May be somewhat
 similar happens with respect to the network location on some phones.
 3. Add listener restart logic after a certain timeout, i.e. if you
 didn't get onLocationChanged() after a certain time stop the listener,
 create and start it again.
 4. Get Android source code and study the LocationManager hierarchy.
 Probably the most complicated approach but I would start from here.

 Best regards
 Igor

 On Nov 30, 3:07 am, michael michael.d.peder...@googlemail.com wrote:







  Hi Igor,

  Thanks for your reply, it is much appreciated. Thanks also for
  pointing out the issues with the code I provided. However, this was
  merely a stripped-down outline of what I am doing. The use of
  mCoarseLocationListener is a type from the strip-down process, and I
  agree that the LocationProvider variable is not necessary.

  However, the problem remains that while the code works fine in 95% of
  cases, there are still 5% of cases where I never get a call to
  onLocationChanged. Any suggestions as to why this is the case would
  still be much appreciated.

  Best,
  Michael.

  On Nov 30, 12:29 am, ip332 iprile...@gmail.com wrote:

   Michael,

   According to Android documentation the following call
   locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
   0, 0, this);
   requests updates from WiFi or cellular network which means you should
   get some update (from cell tower) even if WiFi location is not
   available. However, I've seen cases when Google map application failed
   to set map to MyLocation for several minutes while driving on a
   freeway.

   Back to your code. I think you need to replace
   getLastKnownLocation(mCoarseLocationProvider) with
   getLastKnownLocation(LocationManager.NETWORK_PROVIDER) - it is not
   clear where do you get mCoarseLocationProvider.
   Also you don't need to use LocationProvider variable in your code
   fragment:
        public MyLocationListener() {
            mLocMan =
   (LocationManager)getSystemService(Context.LOCATION_SERVICE);

            if
   (mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) !=
   null) {
                mCurrentLocation =
   mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            }

           
   mLocMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
   this);
        }

   Check the following link which has a lot of useful 
   suggestions:http://developer.android.com/guide/topics/location/obtaining-user-loc...

   Bets regards
   Igor

   On Nov 29, 2:44 pm, michael michael.d.peder...@googlemail.com wrote:

Let me also add that the location listener does sometimes get calls to
onProviderEnabled -- this happens after asking the user to enable
wireless network locations if initially disabled. So I know for sure
that the listener is registered correctly. It just never gets an
onLocationChanged call.

/Michael.

On Nov 29, 10:10 pm, michael michael.d.peder...@googlemail.com
wrote:

 Hi folks,

 I have a location listener running in a foreground service. The
 listener registers for wireless network updates in its constructor. In
 the majority of cases, location updates are received as expected.

 However, log entries from the live app show that for about 5% of my
 users, location updates are never received even though wireless
 network location is enabled on the phone (I check this through the
 LocationManager.isProviderEnabled method). That is, onLocationChanged
 is never called, at least not within say 20 minutes of registering the
 listener.

 Does anybody have any idea why this might be? Are there cases, or
 certain geographic areas, where you would not expect wireless
 locations to be available?

 A stripped-down outline of the location listener code is shown below:

 class MyLocationListener extends LocationListener {
     private Location mLocation = null;

     public MyLocationListener() {
         mLocMan = (LocationManager)
 getSystemService(Context.LOCATION_SERVICE);

         if (mLocMan.getLastKnownLocation(mCoarseLocationProvider) !=
 null) {
             mCurrentLocation =
 mLocMan.getLastKnownLocation(mCoarseLocationProvider);
         }

         LocationProvider lp =
 mLocMan.getProvider(LocationManager.NETWORK_PROVIDER);
         mLocMan.requestLocationUpdates

[android-developers] Re: Geocoder throwing exception

2010-11-30 Thread ip332
Geocoding has nothing in common with GPS but it requires complete
map DB (to search cities and streets)
As we know Google map is stored on the web therefore you must have 3G,
Edge or WiFi channels enabled in order to use Geocoding.


On Nov 30, 1:13 am, saikiran n saikiran@gmail.com wrote:
 Hi,
 I am doing some application to check Geocoder functionality
 I am executing the following code snippet
 Geocoder fwdGeocoder = new Geocoder(this, Locale.US);
         String streetAddress = 160 Riverside Drive, New York, New York;
         ListAddress locations = null;
         try {
         locations = fwdGeocoder.getFromLocationName(streetAddress, 10);
         } catch (IOException e) {
             e.printStackTrace();
             Log.e(TAG, error occured);
         }

 I am testing this app in real device and my apk is build for Google api 2.2
 It is throwing excepion as follows

 01-01 02:27:17.781: WARN/System.err(3186): java.io.IOException: Service not
 Available
 01-01 02:27:17.785: WARN/System.err(3186):     at
 android.location.Geocoder.getFromLocationName(Geocoder.java:159)
 01-01 02:27:17.785: WARN/System.err(3186):     at
 sct.android.geocodertest.TestActivity.onCreate(TestActivity.java:44)
 01-01 02:27:17.785: WARN/System.err(3186):     at
 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
 01-01 02:27:17.785: WARN/System.err(3186):     at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
 01-01 02:27:17.785: WARN/System.err(3186):     at
 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
 01-01 02:27:17.785: WARN/System.err(3186):     at
 android.app.ActivityThread.access$2300(ActivityThread.java:125)
 01-01 02:27:17.785: WARN/System.err(3186):     at
 android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
 01-01 02:27:17.785: WARN/System.err(3186):     at
 android.os.Handler.dispatchMessage(Handler.java:99)
 01-01 02:27:17.785: WARN/System.err(3186):     at
 android.os.Looper.loop(Looper.java:123)
 01-01 02:27:17.789: WARN/System.err(3186):     at
 android.app.ActivityThread.main(ActivityThread.java:4627)
 01-01 02:27:17.789: WARN/System.err(3186):     at
 java.lang.reflect.Method.invokeNative(Native Method)
 01-01 02:27:17.789: WARN/System.err(3186):     at
 java.lang.reflect.Method.invoke(Method.java:521)
 01-01 02:27:17.793: WARN/System.err(3186):     at
 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 
 868)
 01-01 02:27:17.793: WARN/System.err(3186):     at
 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
 01-01 02:27:17.793: WARN/System.err(3186):     at
 dalvik.system.NativeStart.main(Native Method)

 I included the following permissions in manifest file
 uses-permission
 android:name=android.permission.INTERNET/uses-permission
 uses-permission
 android:name=android.permission.ACCESS_FINE_LOCATION/uses-permission
 uses-permission
 android:name=android.permission.ACCESS_COARSE_LOCATION/uses-permission
 My device GPS is turned on
 Any help

-- 
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: listen for GPS updates for definite time

2010-11-30 Thread ip332
Rustam

Location listener doesn't have timing constraint.
Therefore you need to enable listener as usual and create an
asynchronous thread or a timer or something else to check GPS status
after a certain time.
Below is a simple code which does checks GPS fix after 60 seconds.

Best
Igor

// code fragment starts:
private Handler mHandler = new Handler();

private void Start() {
// invoke mGPScheckTask handler (see below) after 60 seconds
interval
mHandler.postDelayed(mGPScheckTask, 60 * 1000);
}

private void Stop() {
mHandler.removeCallbacks(mGPScheckTask);
}

private Runnable mGPScheckTask = new Runnable() {
public void run() {
if( GPSfix )
// do something
else
// do something else
// remove GPS listener here
};


On Nov 30, 1:07 pm, Rustam Kovhaev rkovh...@gmail.com wrote:
 How do I listen for GPS location changes for lets say 5 minutes?
  and if It don't get a single gps fix it removes listener(removeUpdates())

 --
 Regards,
 Rustam Kovhaevhttp://libertadtech.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: LocationListener sometimes not receiving updates from network provider

2010-11-30 Thread ip332
IMHO  getProvider(LocationManager.NETWORK_PROVIDER) should return null
only in two cases:
1. AIRPLANE mode.
2. In case of GSM phone when SIM card is missing and WiFI is disabled
However I tested both cases on Milestone phone (Android 2.1-update1)
and always got some not-null result :(
The only possibility left is that user uses hacked phone, i.e. some
app  which disables Network provider or LocationService removed at
all.
Mistery :)

On Nov 30, 2:01 pm, michael michael.d.peder...@googlemail.com wrote:
 Hi again Igor,

 Thanks for your excellent suggestions, I will work on it over the next
 couple of days.

 As another curiosity, I am experiencing a very small number of cases
 where LocationManager.getProvider(LocationManager.NETWORK_PROVIDER)
 returns null. Apparently some phones do not have this capability.

 Best,
 Michael.

 On Nov 30, 7:57 pm, ip332 iprile...@gmail.com wrote:







  One more thing: check how and when do you remove listener.

  On Nov 30, 11:52 am, ip332 iprile...@gmail.com wrote:

   Michael

   Here are some suggestions:
   1. Additional logging: mCoarseLocationListener details, WiFi status,
   cell signal status (may be in those 5% cases users don't have any
   signal?)
   2. Get details from users about phone models, running applications and
   Android versions. Recently I found interesting feature on Motorola
   phone: sensors do not report events unless the values have been
   changed - this is a violation of the Android API. May be somewhat
   similar happens with respect to the network location on some phones.
   3. Add listener restart logic after a certain timeout, i.e. if you
   didn't get onLocationChanged() after a certain time stop the listener,
   create and start it again.
   4. Get Android source code and study the LocationManager hierarchy.
   Probably the most complicated approach but I would start from here.

   Best regards
   Igor

   On Nov 30, 3:07 am, michael michael.d.peder...@googlemail.com wrote:

Hi Igor,

Thanks for your reply, it is much appreciated. Thanks also for
pointing out the issues with the code I provided. However, this was
merely a stripped-down outline of what I am doing. The use of
mCoarseLocationListener is a type from the strip-down process, and I
agree that the LocationProvider variable is not necessary.

However, the problem remains that while the code works fine in 95% of
cases, there are still 5% of cases where I never get a call to
onLocationChanged. Any suggestions as to why this is the case would
still be much appreciated.

Best,
Michael.

On Nov 30, 12:29 am, ip332 iprile...@gmail.com wrote:

 Michael,

 According to Android documentation the following call
 locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
 0, 0, this);
 requests updates from WiFi or cellular network which means you should
 get some update (from cell tower) even if WiFi location is not
 available. However, I've seen cases when Google map application failed
 to set map to MyLocation for several minutes while driving on a
 freeway.

 Back to your code. I think you need to replace
 getLastKnownLocation(mCoarseLocationProvider) with
 getLastKnownLocation(LocationManager.NETWORK_PROVIDER) - it is not
 clear where do you get mCoarseLocationProvider.
 Also you don't need to use LocationProvider variable in your code
 fragment:
      public MyLocationListener() {
          mLocMan =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);

          if
 (mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) !=
 null) {
              mCurrentLocation =
 mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
          }

         
 mLocMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
 this);
      }

 Check the following link which has a lot of useful 
 suggestions:http://developer.android.com/guide/topics/location/obtaining-user-loc...

 Bets regards
 Igor

 On Nov 29, 2:44 pm, michael michael.d.peder...@googlemail.com wrote:

  Let me also add that the location listener does sometimes get calls 
  to
  onProviderEnabled -- this happens after asking the user to enable
  wireless network locations if initially disabled. So I know for sure
  that the listener is registered correctly. It just never gets an
  onLocationChanged call.

  /Michael.

  On Nov 29, 10:10 pm, michael michael.d.peder...@googlemail.com
  wrote:

   Hi folks,

   I have a location listener running in a foreground service. The
   listener registers for wireless network updates in its 
   constructor. In
   the majority of cases, location updates are received as expected.

   However, log entries from the live app show that for about 5% of 
   my
   users, location updates are never received

[android-developers] Re: Drawing a circle on a MapView to mark the accuracy of the location estimation ?

2010-11-29 Thread ip332
drawCircle requires diameter in pixels. In order to convert accuracy
(in meters from LocationProvider) into pixels you can do this:
- convert current location (GeoPoint) into pixels using
mapView.getProjection.toPixels()
- create another GeoPoint with longitude = center.getlatitudeE6() +
accuracy * 11
- also convert this position into pixels
- get delta between Y coordinates those two points. This is the radius
of your circle.


On Nov 28, 4:05 pm, TreKing treking...@gmail.com wrote:
 On Sun, Nov 28, 2010 at 4:42 PM, Emre A. Yavuz eayl...@hotmail.com wrote:

  Does anybody have a piece of code or a link that can guide me to draw a
  circle on a MapView to mark the accuracy of the location estimation ?

  Is using GPolygon() the only way ?

 No, you can just use this:
 Canvas.drawCircle()http://developer.android.com/reference/android/graphics/Canvas.html#d...
 .

 --- 
 --
 TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
 transit tracking app for Android-powered devices

-- 
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: LocationListener sometimes not receiving updates from network provider

2010-11-29 Thread ip332
Michael,

According to Android documentation the following call
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
0, 0, this);
requests updates from WiFi or cellular network which means you should
get some update (from cell tower) even if WiFi location is not
available. However, I've seen cases when Google map application failed
to set map to MyLocation for several minutes while driving on a
freeway.

Back to your code. I think you need to replace
getLastKnownLocation(mCoarseLocationProvider) with
getLastKnownLocation(LocationManager.NETWORK_PROVIDER) - it is not
clear where do you get mCoarseLocationProvider.
Also you don't need to use LocationProvider variable in your code
fragment:
     public MyLocationListener() {
         mLocMan =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);

         if
(mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) !=
null) {
             mCurrentLocation =
mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
         }

        
mLocMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
this);
     }


Check the following link which has a lot of useful suggestions:
http://developer.android.com/guide/topics/location/obtaining-user-location.html

Bets regards
Igor


On Nov 29, 2:44 pm, michael michael.d.peder...@googlemail.com wrote:
 Let me also add that the location listener does sometimes get calls to
 onProviderEnabled -- this happens after asking the user to enable
 wireless network locations if initially disabled. So I know for sure
 that the listener is registered correctly. It just never gets an
 onLocationChanged call.

 /Michael.

 On Nov 29, 10:10 pm, michael michael.d.peder...@googlemail.com
 wrote:







  Hi folks,

  I have a location listener running in a foreground service. The
  listener registers for wireless network updates in its constructor. In
  the majority of cases, location updates are received as expected.

  However, log entries from the live app show that for about 5% of my
  users, location updates are never received even though wireless
  network location is enabled on the phone (I check this through the
  LocationManager.isProviderEnabled method). That is, onLocationChanged
  is never called, at least not within say 20 minutes of registering the
  listener.

  Does anybody have any idea why this might be? Are there cases, or
  certain geographic areas, where you would not expect wireless
  locations to be available?

  A stripped-down outline of the location listener code is shown below:

  class MyLocationListener extends LocationListener {
      private Location mLocation = null;

      public MyLocationListener() {
          mLocMan = (LocationManager)
  getSystemService(Context.LOCATION_SERVICE);

          if (mLocMan.getLastKnownLocation(mCoarseLocationProvider) !=
  null) {
              mCurrentLocation =
  mLocMan.getLastKnownLocation(mCoarseLocationProvider);
          }

          LocationProvider lp =
  mLocMan.getProvider(LocationManager.NETWORK_PROVIDER);
          mLocMan.requestLocationUpdates(lp.getName(), 0, 0, this);
      }

      public void onLocationChanged(Location loc) {
          mLocation = loc;
      }

  }

  I verify through flurry logs that the network location provider is
  indeed obtained and enabled, and that mLocation == null after about 20
  minutes.

  Any suggestions would be enormously appreciated. I am running out of
  ideas for how to fix this, and I cannot replicate the issue on my own
  test devices.

  Cheers,
  Michael.

-- 
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: about gps

2010-11-23 Thread ip332
Obviously LastKnownLocation can return not null only if someone
turns GPS on and gets a position fix.
You need to create a listener for this particular location provider
and stop it after the first position is reported (not after the first
one).

Of course it would be better to see getBestKnownLocation() in the
LocationManager but I guess Google found the definition of best is
too fuzzy ;)

On Nov 23, 2:28 am, Leon Li l...@leonstrip.com wrote:
 hi all:
 i use Location location=manager.getLastKnownLocation(gps) to get
 real gps,but it allways return null,and i walk around outside office
 long time.
 but if i use network,it work.

 dose anyone else know what is wrong?

-- 
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 LBS Apps

2010-11-23 Thread ip332
Yes, sure. Use Overlay to show your objects on top of the Google Map.

On Nov 19, 1:35 am, karl_os hayashita...@gmail.com wrote:
 Hi all,
 i'm newbie in developing Android Apps. Currently, i'm going to build
 an android Location Based Service apps for my undergraduate thesis.
 I've read some articles about displaying maps in Android but most of
 them are using Google Maps. Since i'm going to use my own custom map,
 is there any way to load my map in Android?
 Thanks.

-- 
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: Geofence application in android

2010-11-22 Thread ip332
As you know, location updates are requested from LocationProvider.
If you use NetworkProvider then GPS is not turned on.
The rest is in technical details which you should get from the
documentation (probably iPhone does it all by itself but in case of
Android some technical boring reading is required ;)
http://developer.android.com/reference/android/location/LocationManager.html#NETWORK_PROVIDER

On Nov 17, 11:36 am, victor lima victorloureirol...@gmail.com wrote:
 http://en.wikipedia.org/wiki/Geofence

 How would I go about doing a geofence characteristic in my android
 app? I dont want to be pooling the GPS hardware for location, and then
 making some calculations to see if the current lat/lng location is
 inside ( or not ) a delimited area. On iPhone ( dont know if I can
 mention iphone here ;)) I can use some system API to notify me upon
 entering/leaving a certain region that I had pre-determined in my
 app... Is there anything that relates to that? How does android apps
 do it? ;)

 Thanks in advance,
 Victor Lima

-- 
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: Zooming on a custom overlay

2010-11-17 Thread ip332
I used the Overlay class for this purpose.
Here is the main part of the MyOverlay::Draw() method:
// convert bitmap's bounding box into pixels
Point top_left = new Point();
mapView.getProjection().toPixels(min, top_left);
Point bottom_right = new Point();
mapView.getProjection().toPixels(max, bottom_right);

// Prepare two rectangles (pixels)
Rect src = new Rect( 0,0,bmp.getWidth() - 1, bmp.getHeight() - 1 );
Rect dst = new Rect( top_left.x, bottom_right.y,
bottom_right.x,top_left.y );

// draw bitmap
canvas.drawBitmap( bmp, src, dst, null);

Since it uses current mapView then zooming and panning are supported
automatically.

Obviously you need to now left top (GeoPoint min in the code above)
and right bottom (GeoPoint max) coordinates for your picture (I used
Google Earth for this purpose).

Good luck.
Igor

On Nov 17, 7:52 am, Allan Valeriano allvaleri...@gmail.com wrote:
 Hi all,

 does anybody knows if it is possible to zoom in and out on a custom
 overlay and enlarge the image?
 I'd like to do something like that:http://geoserver.nima.puc-rio.br/puc-rio/

 If you zoom in, you'll notice that the image gets bigger.

-- 
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: Access sensors' data directly

2010-11-17 Thread ip332
Short answer: no, you can't read sensors directly. With some hacking
steps and couple of weeks of hard work you might be able to duplicate
Android's Sensors JNI with exactly the same (or even worse)
performance which will work only on your super-rooted-hacked-one-of-a-
kind phone. Why bother?

With respect to the second question: yes, you can, but the maximum
speed is device (driver) dependent and sometimes could be too high for
the device. I mean that reading sensors is not the final goal and you
need to keep some CPU to process that data, right?
Anyway, you need to start from reading Android documentation:
http://developer.android.com/reference/android/hardware/SensorManager.html#registerListener(android.hardware.SensorEventListener,
android.hardware.Sensor, int)


On Nov 13, 12:24 pm, babak bnade...@gmail.com wrote:
 Hello all,

 I am looking for a way to get sensors' data ( especially
 Accelerometer) directly without using Listener approach. Actually I
 need to have the data really fast!!!

 I can not find any way to read sensor data by myself. Anybody knows
 anything about it?
 Is it possible to read data with more than 50Hz?

 Regards,
 Babak

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