[android-developers] JUnit on the emulator without instrumentation

2009-03-24 Thread gudujarlson

I would like to write, run, and debug JUnit tests that test non-GUI
code that has dependencies on the Android SDK. Is there a simple way
to do that? I'm aware of the instrumentation mechanism, but that seems
to be geared towards testing GUI code. It is also unclear how to use
the instrumentation mechanism with Eclipse and also the debugger.
I've tried simply writing tests using the classes in android.test and
running them via AndroidTestRunner invoked from a button click on an
Activity, but I get the following error when I try to run the
application.

W/dalvikvm(  594): VFY: unable to resolve new-instance 8 (Landroid/
test/AndroidTestRunner;) in Lcom/spike/AndroidSpike$2;

For completeness, here is the complete code for the Activity.

package com.spike;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.test.*;

public class AndroidSpike extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((Button)this.findViewById
(R.id.runTestsButton)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AndroidTestRunner runner = new 
AndroidTestRunner();
runner.setTest(AllTests.suite());
runner.runTest();
}
});
}
}
--~--~-~--~~~---~--~~
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] Drop entire database?

2009-03-24 Thread gudujarlson

I have an automated test that creates a SQLite database. In the setup
of the test I want to drop the database if it already exists. The
problem is that I cannot find a function that deletes/drops a
database. That seems like an odd omission. 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: Drop entire database?

2009-03-24 Thread gudujarlson

I found the answer to my own question.

http://developer.android.com/reference/android/content/Context.html#deleteDatabase(java.lang.String)

The context class is not where I would expect to find the function to
delete a SQLite database. Wouldn't it be more intuitive to have this
function on the SQLiteDatabase class?

On Mar 24, 11:24 pm, gudujarlson gudujarl...@gmail.com wrote:
 I have an automated test that creates a SQLite database. In the setup
 of the test I want to drop the database if it already exists. The
 problem is that I cannot find a function that deletes/drops a
 database. That seems like an odd omission. 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: JUnit on the emulator without instrumentation

2009-03-25 Thread gudujarlson

Assuming there is no easy way to make use of android.test without
instrumentation, has anyone tried to do their own port of JUnit (or
similar framework) to the android platform? On Windows Mobile I am
using NUnitLite. Does JUnitLite exist?


--~--~-~--~~~---~--~~
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: Drop entire database?

2009-03-25 Thread gudujarlson

 The Context class has a suite of functions for creating, opening, and
 deleting databases at the standard location of databases for your app.

 The SQLiteDatabase class can be used to access a databases at any absolute
 path.  In that case, you are using an absolute path, so use File to delete
 the database file at that path.

 But unless you are putting your database on the SD card, you would be best
 off using the Context methods for your database access.

Ah ok, I think I get it now. I can just treat the database like a
normal file. It wasn't obvious at first that I could go under the
covers and manipulate the database via the filesystem API.


--~--~-~--~~~---~--~~
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: JUnit on the emulator without instrumentation

2009-03-27 Thread gudujarlson

I discovered that at least some of JUnit exists on the emulator. In
particular TestCase and Assert exist. However, TestRunner does not
appear to exist. I find it odd that only parts of JUnit are present.

--~--~-~--~~~---~--~~
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: JUnit on the emulator without instrumentation

2009-04-06 Thread gudujarlson

Thanks for the response. I am aware of the instrumentation mechanism
to run tests, however I have been unable to determine how to use it in
conjunction with the debugger in eclipse, thus it is essentially
useless to me.

On Apr 5, 11:10 pm, Andrew Stadler stad...@gmail.com wrote:
 It's actually quite useful and doable to write pure unit tests
 within the InstrumentationTestRunner framework.

 For a working example, please take a look at ApiDemos, in the tests/
 directory, and look for classes that extend the TestCase class.

 Benefits of doing it this way:

 1.  Although you can restrict yourself to pure JUnit style tests if
 you want, you can also write a mix of tests, ranging from purely unit
 (extending TestCase and AndroidTestCase) to almost totally functional
 (e.g. extending ActivityInstrumentationTestCase) and group them
 together as a test suite.

 2.  Although it doesn't work in the published SDK, quite soon you will
 in fact be able to run these tests directly from Eclipse.  In other
 words, because this is the supported mechanism, you'll benefit from
 upcoming improvements  tools.

 Hope this helps.

 --Andy

 On Fri, Mar 27, 2009 at 10:15 PM, gudujarlson gudujarl...@gmail.com wrote:

  I discovered that at least some of JUnit exists on the emulator. In
  particular TestCase and Assert exist. However, TestRunner does not
  appear to exist. I find it odd that only parts of JUnit are present.
--~--~-~--~~~---~--~~
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: Drop entire database?

2009-04-06 Thread gudujarlson

Thank you, Sirius, but my question was how to drop the entire
database, not just one table.
--~--~-~--~~~---~--~~
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: Poll Screen On/Off state

2009-11-03 Thread gudujarlson
 You can't poll screen on/off state.  The best you can do is to
 register a BroadcastReceiver, and wait for an Intent to come along.
 Until that first Intent is received, you'll have no idea what the
 screen state is.

Yes, that is how it appears and thus why I posted. It seems like a
important omission from the API.

-- 
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: Poll Screen On/Off state

2009-11-03 Thread gudujarlson
 Monitor the ACTION_SCREEN_OFF and ACTION_SCREEN_ON Intents, then. If
 your application starts based on a user action, then you know the screen
 is on at that point -- you don't need an API for that.

That occured to me, but I'm not confident that it would be reliable. I
don't like the idea of listening for 2 events, storing a status for
later use, and hoping that I never miss an event or start with the
screen off. One possible troublesome scenario occurs when the app
starts really slow for some reason and before the listener is
registered, the user turns the screen off.

-- 
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] Poll Screen On/Off state

2009-11-03 Thread gudujarlson

I have an app that runs in the background indefinitely provided there
is work to be done. I want the app to go to sleep if there is no work
to be done and the user is idle. The second part has me stumped. On
Windows Mobile I was able to poll the power state to determine user
idleness. On BlackBerry I was able to poll the device idle time.
However, there does not appear to be a way to determine user idleness
on Android.

Instead of polling for user idleness directly, I thought I might be
able to use the on/off state of the screen. There are 2 intents
ACTION_SCREEN_OFF and ACTION_SCREEN_ON and I was able to setup a
listener for these (BroadcastReceiver). The problem is that I do not
know how to determine the current state of the screen at the time I
register the listener, therefore I have to wait until the next screen
on/off change to know anything. The docs speak of some intents that
are sticky and thus will allow the current state to be determined,
but the screen events do not appear to have that property. What am I
to do?

In general, I find the lack of support for polling system state
properties (e.g. screen state, power state, signal strength) in
Android to be annoying. It's cool that one can listen for changes in
system state rather than constantly polling for them, but one still
needs to know the current state of the property at the time the
listener is registered. Am I missing something fundamental?




-- 
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: Poll Screen On/Off state

2009-11-03 Thread gudujarlson
 What does the user being idle have to do with anything here? If there is
 no work to be done, there is no work to be done, so stop your service
 and wake it up after some time to see if there is new work to be done.

Well, I simplified the situation in an attempt to make my post
succinct. The app runs in the background and records information
including the device's location, but it also has a user interface.
What I want to prevent is draining the user's battery when they go
inside where there is no GPS signal and forget to turn off the app.
There is no point in running when there is no GPS fix and the user is
not watching the display. However, if the user is interacting with the
app, I want it to continue to run regardless of the lack of a GPS fix,
because useful information is still displayed and that information
requires continuous background processing.

 Power is available on demand via a sticky Intent.

The power state information that would be useful is not available as
far as I know. Windows Mobile has different power states such as ON,
OFF, and USERIDLE. I have not found the equivalent in Android.

 WiFi signal strength is available on demand via WifiManager.

I don't need this currently.

 GSM/CDMA signal strength is available on demand from TelephonyManager.

As far as I know, you cannot poll for signal strength and the event is
only triggered when the signal strength changes by quite a large
amount. Additionally. the event stops being raised when the screen
turns off. There is a poll function in the service (I looked through
the source), but it is not exposed in the SDK. There is a open feature
request related to 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] CDMA home carrier

2009-12-02 Thread gudujarlson
How does one determine the home carrier on a CDMA phone? By home
carrier I mean the carrier that the phone's owner has a contract with,
not the owner of the cell site that the phone is communicating with.
These are different when the phone is roaming. On a GSM phone I can
get the home carrier from the IMSI recorded on the SIM, but this does
not work on a CDMA phone. CDMA has a similar identifier called home
system ID. Is there a way to query the home system ID? If that is not
possible, how do I determine the home carrier? On Windows Mobile I am
forced to search the registry looking for strings like 'Verizon' and
'Sprint'. Is there a similar klooge on 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: CDMA home carrier

2009-12-02 Thread gudujarlson
What you are referring to is information about the current cell tower,
not the home operator. On a GSM phone, you can get the home operator
with TelephonyManager.getSimOperator(), but on a CDMA phone it returns
a bogus value.

On Dec 2, 6:14 pm, Ken H hunt1...@gmail.com wrote:
 On GSM I use:

 TelephonyManager tm  = (TelephonyManager) getSystemService
 (Context.TELEPHONY_SERVICE);
 String Operator = tm.getNetworkOperatorName();

 I assume CDMA is the same since I've seen nothing in the docs that say
 otherwise. Also, for CDMA you can get SystemID  etc., by using:

 CdmaCellLocation cd = (CdmaCellLocation) tm.getCellLocation();
 int sysid = cd.getSystemId();
 int netid = cd.getNetworkId();
 int bsid = cd.getBaseStationId();

 I can't test this last part out since I have a GSM phone. You can also
 look at:

 http://developer.android.com/intl/fr/reference/android/telephony/cdma...

 Ken

-- 
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: CDMA home carrier

2009-12-03 Thread gudujarlson
The home operator is the operator you pay your bill to and get
customer service from. The cell site you are currently talking to may
not be owned by the same operator. When this happens, you are
(sometimes?) considered to be roaming. As far as I know, all the
functions you mentioned give information about the current cell site,
not the home operator. So for example, if I had a contract with ATT
and I was in Seattle, both the current cell site and the home operator
are the same, but if I traveled to Vancouver, Canada the cell site
would be owned by Rogers and those functions would return the MCC and
MNC of Rogers, not ATT. The GSM API on Android, Windows Mobile, and
Blackberry allow you to differentiate between the home and current
operator, but with CDMA it gets tricky. Blackberry makes it easy by
providing a function that returns the home SID, but neither Windows
Mobile nor Android provide a similar function.

I have not tested getNetworkOperatorName() in a roaming situation, but
my assumption is that it returns the carrier that owns the current
cell site. I think this because the documentation says ... of current
registered operator. I understand registration to be the process
the phone goes through when handshaking with a cell site.

Here are the interesting GSM functions in Android:

TelephonyManager.getSimOperator()
Returns the home operator (MCC + MNC). It just returns the first
part of the IMSI stored on the SIM.

ServiceState.getOperatorNumeric()
Returns the current operator (MCC + MNC). This is retrieved from
the current cell site.

GsmCellLocation.getLac()
Returns the Location Area Code of the current cell site.

GsmCellLocation.getCid()
Returns the Cell ID of the current cell site.

Some of these have CDMA equivalents:

TelephonyManager.getSimOperator()
In non world phones, this returns the first 6 digits of the IMSI
(e.g. 314). This is bogus, because CDMA IMSI's have 00 for the MNC
which 2 digits not 3 and useless either way. The 4 on the end is
actually the beginning of the subscriber ID. This is a bug in Android
as far as I can tell. In world phones, it will probably return the MCC
+MNC for an operator in Europe.

ServiceState.getOperatorNumeric()
Returns the MCC + 00. This is mostly useless, because it does not
identify the carrier.

CdmaCellLocation.getSystemId()
Returns the System ID of the current cell cite (this identifies
the operator that owns the cell site). It is analogous to MNC.

CdmaCellLocation.getNetworkId()
Returns the Network ID of the current cell site. It is analogous
to LAC.

CdmaCellLocation.getBaseStationId()
Returns the Base Station ID of the current cell site, It is
analogous to CID.

What is missing is a CDMA equivalent of TelephonyManager.getSimOperator
() that returns the home SID.

On Dec 2, 7:18 pm, Ken H hunt1...@gmail.com wrote:
 I think I'm getting confused by what you mean by home operator and
 current cell tower.

 The getNetworkOperatorName() method will get you the network or
 carrier your phone is on (T-Mobile for example). I assume that is
 what you mean by home operator.

 Technically there is nothing that tells you the cell tower. Mobiles
 don't talk to towers, they talk to cells, or sectors, on the tower.
 Most towers -- or cell sites, since they can be located anywhere, not
 just on poles -- have 3 sectors. Depending or your location relative
 to that site your mobile may be talking to sector A, B or C. In GSM
 the cells are uniquely identified by the CGI which consist of the
 mobile country code (MCC), mobile network code (MNC), location area
 code (LAC), and Cell ID. You can get MCC  MNC by using
 getNetworkOperator(), and you can get the LAC  CI by using

 GsmCellLocation cl = (GsmCellLocation) tm.getCellLocation();
 int CELLID = cl.getCid();
 int LAC = cl.getLac();

 But again, this is GSM. The method I mentioned in my first post
 *should* get you the CDMA version of the System ID, Network ID, and
 Base Station ID, which will uniquely identify the cell you are current
 on.

 Ken

 On Dec 2, 4:22 pm, gudujarlson gudujarl...@gmail.com wrote:

  What you are referring to is information about the current cell tower,
  not the home operator. On a GSM phone, you can get the home operator
  with TelephonyManager.getSimOperator(), but on a CDMA phone it returns
  a bogus value.

  On Dec 2, 6:14 pm, Ken H hunt1...@gmail.com wrote:

   On GSM I use:

   TelephonyManager tm  = (TelephonyManager) getSystemService
   (Context.TELEPHONY_SERVICE);
   String Operator = tm.getNetworkOperatorName();

   I assume CDMA is the same since I've seen nothing in the docs that say
   otherwise. Also, for CDMA you can get SystemID  etc., by using:

   CdmaCellLocation cd = (CdmaCellLocation) tm.getCellLocation();
   int sysid = cd.getSystemId();
   int netid = cd.getNetworkId();
   int bsid = cd.getBaseStationId();

   I can't test this last part out since I have a GSM phone. You can also
   look at:

  http://developer.android.com

[android-developers] Re: CDMA home carrier

2009-12-04 Thread gudujarlson
 But don't get me started on Android 2.0 and this CDMA stuff. Example:
 the CdmaCellLocation has two methods (getBaseStationLatitude() 
 getBaseStationLongitude()) which, judging from the name return the LAT/
 LON of the site. Great, I'm thinking until I look at the datatype and
 see that they are both INTs. Which, again, wouldn't be a problem if
 they said, To get the decimal value divide by 1,000,000, but they
 don't. Another beautiful mystery is that onSignalStrengthChanged has
 been depracated, but they don't state what the replacement is.

Ya tell me about it. Signal strength is expressed in a made up unit
(ASU), stops updating when the screen turns off, and is artificially
capped at -63 dBm (at least on the G1). In the Android source code
there is a function for polling the signal strength, but it is not
exposed to the public. There is a open bug related to this:
http://code.google.com/p/android/issues/detail?id=700q=RILcolspec=ID%20Type%20Status%20Owner%20Summary%20Stars

-- 
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 build apk from multiple Eclipse projects?

2009-12-16 Thread gudujarlson
It is quite a bummer that Android resources cannot be distributed in a
jar. One possible work-around that comes to mind is writing up a
simple tool to convert resources to java literals and compiling these
into your project.  For example:

public static final byte myresource[] = {0x45,0x23,0x8F};

Obviously, real resources would be much larger.

As long as you never need to call an API that expects a Android
resource ID, this should be a poor mans replacement for Android
resources. I am going to try this approach with a reusable library
that I am working on.

-- 
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 build apk from multiple Eclipse projects?

2009-12-16 Thread gudujarlson
I have been perplexed by the lack of a library concept since my first
look at Android. It seems the Android designers viewed the library
concept as unnecessary. In it's place we have activities, services,
broadcast receivers, and content providers. However, either I am
subborn to new ideas or these concepts are not a full replacement for
libraries, because I have not been able to find solutions to my
problems.

On Dec 16, 9:29 am, Robert Woodruff woodman...@gmail.com wrote:
 It seems that there are solutions to the issue of having jars with
 resources. It probably needs to be incuded as part of the core Android
 development Eclipse extensions rather than individual developers hacking out
 sorta-solutions. The Google engineers are surely aware of this limitation
 because it impacts them as well. Models are available in other java
 development environs so maybe they will serve as inspiration.

-- 
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] HSPA vs HSPA+

2010-11-10 Thread gudujarlson
I don't see a separate constant on android.telephony.TelephonyManager
for HSPA+ (Evolved High-Speed Packet Access). Is there no way to
differentiate between HSPA+ and HSPA/HSUPA/HSDPA?

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