[android-developers] Re: Android sqlite unable open database problem

2010-02-01 Thread Per Sandström
you could simplify your code by using openOrCreateDatabase
(DATABASE_NAME, Context.MODE_PRIVATE, null); instead. :) Maybe then
the problem will resolve itself.

Cheers,
Per Sandström

On Jan 29, 5:52 pm, Josema jose.maria.estr...@gmail.com wrote:
 Hi,

 im doing debug with my mobile. My code works in the past, but now is not
 working and i dont know why i cant create or open an existing database.

 Here is my 
 code:http://stackoverflow.com/questions/2163100/creating-database-in-android

 Could you help me about how to solve this problem?

 I read that there is an option from the command line:

 emulator -wipe-data but since im not using an emulator to debug the
 application (im using my own android mobile), im lost about how to solve the
 problem.

 Thanks in advance.
 Best Regards.
 Josema.

-- 
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: Displaying Virtual Keyboard without expanding EditText

2010-01-28 Thread Per Sandström
I think this works:

InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(
Context.INPUT_METHOD_SERVICE );
inputMethodManager.showSoftInput ( yourEditText,
InputMethodManager.SHOW_FORCED );

you might have to force the edittext to be focused by running
yourEditText.requestFocus() first, Im not sure.

cheers,

On Jan 28, 11:16 am, swapnil kamble swap.kam...@gmail.com wrote:
  I want to display keyboard when my app gets started. I know we can get
 Virtual Keyboard when clicked on EditText field, but I want to show Virtual
 Keyboard without clicking on EditText.

 Swapnil

 || Hare Krishna Hare Krishna Krishna Krishna Hare Hare ||
 || Hare Rama    Hare Rama   Rama   Rama    Hare Hare ||

-- 
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: Copy Protection

2010-01-25 Thread Per Sandström
After turning off copy protection and losing db and local files, are
there any way to restore them?

Regards,
Per Sandström

On Jan 15, 6:10 am, Kumar Bibek coomar@gmail.com wrote:
 Hi Andrei,

 If you don't care about dev phones downloading your app, and ripping
 apart your db and local files, then it's fine.

 Kumar Bibek

 On Jan 15, 6:34 am, Andrei gml...@gmail.com wrote:

  I have Copy Protection turned on for my app, but now i want to
  remove it
  Will there be any problems if i remove it now?
  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: Stack trace does not reference application

2009-12-23 Thread Per Sandström
Im having huge problems with this right now. More and more droid-users
are suffering from it. Is there any information on when this happens,
so maybe I can do a workaround to avoid the crashes until the
plattform is patched?

On 16 Dec, 18:58, Romain Guy romain...@android.com wrote:
 This is a known bug in the platform.

 2009/12/16 Per Sandström pg.sandst...@gmail.com:



 So I have an app on the market with 10k active users. I have recieved 
 maybe 50complaints from Droid-user that the program crashes
  arbitrarily. I have not been able to replicate the error with my own
  droid, but I got one of the to send me this crash log. However, it
  does not reference the application.

  Do you have any suggestions on how to track down this error? I stand
  baffled.

  11-25 16:18:03.730 D/AndroidRuntime( 2964): Shutting down VM
  11-25 16:18:03.730 W/dalvikvm( 2964): threadid=3: thread exiting with
  uncaught exception (group=0x4001b180)
  11-25 16:18:03.730 E/AndroidRuntime( 2964): Uncaught handler: thread
  main exiting due to uncaught exception
  11-25 16:18:03.761 E/AndroidRuntime( 2964): java.lang.

  IndexOutOfBoundsException: getChars (5 ... 0) has end before start
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  android.text.SpannableStringBuilder.checkRange
  (SpannableStringBuilder.java:935)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  android.text.SpannableStringBuilder.getChars
  (SpannableStringBuilder.java:847)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  android.text.TextUtils.getChars(TextUtils.java:69)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  android.text.SpannableStringBuilder.init(SpannableStringBuilder.java:
  59)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  android.text.SpannableStringBuilder.subSequence
  (SpannableStringBuilder.java:839)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  android.widget.TextView.extractTextInternal(TextView.java:4542)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  android.widget.TextView.reportExtractedText(TextView.java:4581)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  android.widget.TextView.finishBatchEdit(TextView.java:4724)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  android.widget.TextView.endBatchEdit(TextView.java:4706)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  com.android.internal.widget.EditableInputConnection.endBatchEdit
  (EditableInputConnection.java:54)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  com.android.internal.view.IInputConnectionWrapper.executeMessage
  (IInputConnectionWrapper.java:334)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  com.android.internal.view.IInputConnectionWrapper
  $MyHandler.handleMessage(IInputConnectionWrapper.java:57)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  android.os.Handler.dispatchMessage(Handler.java:99)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at android.os.Looper.loop
  (Looper.java:123)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  android.app.ActivityThread.main(ActivityThread.java:4310)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  java.lang.reflect.Method.invokeNative(Native Method)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  java.lang.reflect.Method.invoke(Method.java:521)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
  (ZygoteInit.java:860)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  11-25 16:18:03.761 E/AndroidRuntime( 2964): at
  dalvik.system.NativeStart.main(Native Method)
  11-25 16:18:03.777 I/Process ( 1015): Sending signal. PID: 2964 SIG: 3
  11-25 16:18:03.777 I/dalvikvm( 2964): threadid=7: reacting to signal 3
  11-25 16:18:03.832 I/dalvikvm( 2964): Wrote stack trace to '/data/anr/
  traces.txt'
  11-25 16:18:05.543 I/Process ( 2964): Sending signal. PID: 2964 SIG: 9
  11-25 16:18:05.558 I/ActivityManager( 1015): Process myapp.myapp (pid
  2964) has died.

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

 --
 Romain Guy
 Android framework engineer
 romain...@android.com

 Note: please don't send private questions to me, as I don't have time
 to provide private support.  All such questions should be posted on
 public forums, where I and others can see and answer them

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


[android-developers] Stack trace does not reference application

2009-12-16 Thread Per Sandström
So I have an app on the market with 10k active users. I have recieved
maybe 50 complaints from Droid-user that the program crashes
arbitrarily. I have not been able to replicate the error with my own
droid, but I got one of the to send me this crash log. However, it
does not reference the application.

Do you have any suggestions on how to track down this error? I stand
baffled.

11-25 16:18:03.730 D/AndroidRuntime( 2964): Shutting down VM
11-25 16:18:03.730 W/dalvikvm( 2964): threadid=3: thread exiting with
uncaught exception (group=0x4001b180)
11-25 16:18:03.730 E/AndroidRuntime( 2964): Uncaught handler: thread
main exiting due to uncaught exception
11-25 16:18:03.761 E/AndroidRuntime( 2964): java.lang.

IndexOutOfBoundsException: getChars (5 ... 0) has end before start
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
android.text.SpannableStringBuilder.checkRange
(SpannableStringBuilder.java:935)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
android.text.SpannableStringBuilder.getChars
(SpannableStringBuilder.java:847)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
android.text.TextUtils.getChars(TextUtils.java:69)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
android.text.SpannableStringBuilder.init(SpannableStringBuilder.java:
59)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
android.text.SpannableStringBuilder.subSequence
(SpannableStringBuilder.java:839)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
android.widget.TextView.extractTextInternal(TextView.java:4542)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
android.widget.TextView.reportExtractedText(TextView.java:4581)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
android.widget.TextView.finishBatchEdit(TextView.java:4724)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
android.widget.TextView.endBatchEdit(TextView.java:4706)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
com.android.internal.widget.EditableInputConnection.endBatchEdit
(EditableInputConnection.java:54)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
com.android.internal.view.IInputConnectionWrapper.executeMessage
(IInputConnectionWrapper.java:334)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
com.android.internal.view.IInputConnectionWrapper
$MyHandler.handleMessage(IInputConnectionWrapper.java:57)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
android.os.Handler.dispatchMessage(Handler.java:99)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at android.os.Looper.loop
(Looper.java:123)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
android.app.ActivityThread.main(ActivityThread.java:4310)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
java.lang.reflect.Method.invokeNative(Native Method)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
java.lang.reflect.Method.invoke(Method.java:521)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:860)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
11-25 16:18:03.761 E/AndroidRuntime( 2964): at
dalvik.system.NativeStart.main(Native Method)
11-25 16:18:03.777 I/Process ( 1015): Sending signal. PID: 2964 SIG: 3
11-25 16:18:03.777 I/dalvikvm( 2964): threadid=7: reacting to signal 3
11-25 16:18:03.832 I/dalvikvm( 2964): Wrote stack trace to '/data/anr/
traces.txt'
11-25 16:18:05.543 I/Process ( 2964): Sending signal. PID: 2964 SIG: 9
11-25 16:18:05.558 I/ActivityManager( 1015): Process myapp.myapp (pid
2964) has died.

-- 
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] Emulator closes when attempting to enter full screen mode

2009-12-11 Thread Per Sandström
If I am in the emulator and press alt+enter to get full screen, the
emulator closes and the following output is written in the console:

[2009-12-11 15:01:00 - Emulator]### Error: could not create or resize
SDL window: No video mode large enough for 1050x1680

Note that I have my monitor flipped to the side. The resolution isnt
1680*1050, but 1050*1680. This bug has only happened on this
resolution with flipped monitor. I have tried maybe three different
resolutions, but nothing bigger than this. The error is replicable
since it happens everytime I try to go into fullscreen mode. I would
very much prefer if the action was cancelled instead of the emulator
closing.

If there is a more appriopriate place to file a bug report, then
please inform me and I will file it there.

-- 
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] Something wrong here error message

2009-11-27 Thread Per Sandström
I have had a few reports coming in from Droid-users using my apps and
getting this error message:

11-25 16:17:44.589 W/UsageStats( 1015): Something wrong here, didn't
expect (package name) to be resumed

Everytime I have got an error description for this, I have never been
able to reproduce the error on the emulators. Are there any good
information on what exactly this error is? I have a hard time
imagining what such an error message can really mean.

-- 
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] Changing the factory reset-state

2009-11-24 Thread Per Sandström
I am in a situation where I want to make alot of android-phones fool-
proof, so that a company or agency can distribute phones with certain
apps installed, and maybe even the apps configured in a certain way.
It should be easy to reset the phone to this state, perhaps through
the factory reset. Is there any documentation on how to do this? I see
this as something very important for Android to be used in these
contexts. Relying on the personell to configure and care for the
settings of their phone is not an option in this case.

Cheers,
Per Sandström

-- 
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: Our app is not visible on market for some devices

2009-11-23 Thread Per Sandström
I have seen other discussions where is seems as if the general
consensus is that the market is bugged. Apps will simply arbitrarily
not show for some phones. Our company has suffered the same way, and I
have yet to find a solution. Two exact identical phones, both had just
been factory resetted,only one can find our app.

On Nov 23, 11:30 pm, Klaus Kartou kar...@gmail.com wrote:
 This thread is a follow up from that thread. I contacted Google´s market
 support about this issue, but haven't received a reply...
 I would really be interested in an official response to this issue. We have
 many people that complains about not being able to download our app.

 On Mon, Nov 23, 2009 at 11:20 PM, String sterl...@addressender.com wrote:
  According to this thread:

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

  apps with a manifest permission of CAMERA don't seem to appear on the
  Market from the Tattoo. No explanation yet of why, or if anyone from
  HTC/Google is aware of the problem, or what you can do about it if
  your app requires the camera.

  String

  On Nov 23, 9:15 pm, Klaus Kartou kar...@gmail.com wrote:
   Thank you for your fast response!
   We havent activated copy protection, so that is not the issue.

   On Mon, Nov 23, 2009 at 10:11 PM, Greg Donald gdon...@gmail.com wrote:
On Mon, Nov 23, 2009 at 3:10 PM, Klaus Kartou kar...@gmail.com
  wrote:
 Our app does not show up on the market on HTC Tattoo/Dragon devices.

Copy protection bug.  If you disable it your app will probably appear.

--
Greg Donald
   http://destiney.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.comandroid-developers%2bunsubscr...@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%2bunsubscr...@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] signal when image is rendered?

2009-09-04 Thread Per Sandström

I have a function that performs two things: First it should set an
invisible image to be visible, and then it should read a huge shunk of
data from a database. Performing this is easy, but my problem is that
android threads this, resulting in a delay of almost a second before
the image becomes visible. I have tried extending the images draw-
function, and initiating the database-read when draw() is finished,
but it seems that when the draw-function finishes the image is not yet
visible on the screen. How should I find out when the image actually
is visible?
--~--~-~--~~~---~--~~
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] Log in to google account without browser?

2009-09-03 Thread Per Sandström

Hi,

Im currently trying to combine android and google apps engine for a
real neat application, not unlike http://3banana.com/. However I want
to enable the user to login to his google account without opening the
browser. I have made some attempts to just simulate the http-posts
done, but to no avail. Are there any nice way of doing this google
account login in android code?

For example, to make my own loginscreen, and then send user/pass to
the google apps server and get an aknowledgement if the login
information was correct.
--~--~-~--~~~---~--~~
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] change color of fading edge in listview

2009-08-07 Thread Per Sandström

i have a listview with a very white layout. Thus I wish the fading
edge was black, instead of white as it is right now. How can I change
this? As far as I can see it cant be done in xml...
--~--~-~--~~~---~--~~
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: Sharing data between activities

2009-08-05 Thread Per Sandström

thanks man, that is an excellent way of explaining so even an android-
beginner can understand. Is there a similar way of returning data to
the first activity when the second activity has finished running,
corresponding to javas return value1;?

Regards
Per Sandström

On 4 Aug, 17:44, powerbyte powerb...@gmail.com wrote:
 Hello

 To summarize: Activities don't have constructors! How do I send data
 to them from their parent activity???

 we can send data from parent activity to childs, using Intent

 for example:

 In parent activity,

   Intent intent = new Intent(this,com.sample.aaa.class); //aaa is
 child activity
   intent.putExtra(ARG1,value1);
   intent.putExtra(ARG2,value2);
   StartActivity(intent);

 In Child activity (aaa) use Bundle to get the data

   public void onCreate(Bundle som) {
         super.onCreate(som);

          Intent intent = this.getIntent();
          Bundle b = intent.getExtras();
          String sVal1 =  b.getString(ARG1);
          String sVal2 =  b.getString(ARG2);
           
           ...

 }

 -pb

 On Aug 4, 6:31 pm, Per Sandström pg.sandst...@gmail.com wrote:

  but how do I create and pass this global object? I cant do it like I
  do in java or other programming languages where . AIDL is an
  alternative, but it still seems overkill for a small app.

  regards
  Per Sandström

  On Jul 22, 10:50 pm, niko20 nikolatesl...@yahoo.com wrote:

   On Jul 22, 1:19 pm, Roman roman.baumgaert...@t-mobile.com wrote:

Android supports multiple IPC mechanisms.

You can use the Intent mechanism as well as the AIDL mechanism for
doing this. The AIDL approach is more complex but offers you also more
flexibility to pass objects.

Find information about this topic on

   http://developer.android.com/guide/developing/tools/aidl.html

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.

On Jul 22, 6:49 am, PerSandströmpg.sandst...@gmail.com wrote:

 So far I have been using SharedPreferences to share data between
 activities. But I would very much like to find a better way. I would
 simply like both Activity1 and Activity2 to share Object1. Activity1
 will create Object1 and then start Activity2. What is the smartest way
 to give Activity2 a pointer to Object1?

 To summarize: Activities don't have constructors! How do I send data
 to them from their parent activity???

 Regards,
 PerSandström

   Hi,

   If both activities are in the same application, then just use a global
   object and pass that around (singleton or such). Not too tough.

   -niko- 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: Sharing data between activities

2009-08-04 Thread Per Sandström

but how do I create and pass this global object? I cant do it like I
do in java or other programming languages where . AIDL is an
alternative, but it still seems overkill for a small app.

regards
Per Sandström

On Jul 22, 10:50 pm, niko20 nikolatesl...@yahoo.com wrote:
 On Jul 22, 1:19 pm, Roman roman.baumgaert...@t-mobile.com wrote:



  Android supports multiple IPC mechanisms.

  You can use the Intent mechanism as well as the AIDL mechanism for
  doing this. The AIDL approach is more complex but offers you also more
  flexibility to pass objects.

  Find information about this topic on

 http://developer.android.com/guide/developing/tools/aidl.html

  --
  Roman Baumgaertner
  Sr. SW Engineer-OSDC
  ·T· · ·Mobile· stick together
  The views, opinions and statements in this email are those of the
  author solely in their individual capacity, and do not necessarily
  represent those of T-Mobile USA, Inc.

  On Jul 22, 6:49 am, PerSandströmpg.sandst...@gmail.com wrote:

   So far I have been using SharedPreferences to share data between
   activities. But I would very much like to find a better way. I would
   simply like both Activity1 and Activity2 to share Object1. Activity1
   will create Object1 and then start Activity2. What is the smartest way
   to give Activity2 a pointer to Object1?

   To summarize: Activities don't have constructors! How do I send data
   to them from their parent activity???

   Regards,
   PerSandström

 Hi,

 If both activities are in the same application, then just use a global
 object and pass that around (singleton or such). Not too tough.

 -niko
--~--~-~--~~~---~--~~
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] Sharing data between activities

2009-07-22 Thread Per Sandström

So far I have been using SharedPreferences to share data between
activities. But I would very much like to find a better way. I would
simply like both Activity1 and Activity2 to share Object1. Activity1
will create Object1 and then start Activity2. What is the smartest way
to give Activity2 a pointer to Object1?

To summarize: Activities don't have constructors! How do I send data
to them from their parent activity???

Regards,
Per Sandström
--~--~-~--~~~---~--~~
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: using touch screen to draw a straight line

2009-04-14 Thread Per Sandström

Here is another bug in the code:

if(i == 0) {
static_x = event.getX();
static_y = event.getY();
i = 1;
} else
{
static_x1 = event.getX();
static_y1 = event.getY();

}
   // want to draw a line at this stage after figuring out two
screen
touches have been performed ??
   if(i == 1) {

As you can see, you set i = 1 on the first time this function is
called. Thus the second if-statement is always true. Add an else
before the last if

On Apr 14, 2:12 am, gandor gand...@gmail.com wrote:
 Hi Folks,

 Want to draw a line when I touch screen at two points.
 I can see OnTouch been invoked but after than everything breaks looks,
 the application crashes

 I am using drawLine in Canvas.
 Please let me know what I am doing wrong

 Thanks a ton

 
 ?xml version=1.0 encoding=utf-8?
 LinearLayout xmlns:android=http://schemas.android.com/apk/res/
 android
     android:id=@+id/layout_id
     android:orientation=vertical
     android:layout_width=fill_parent
     android:layout_height=fill_parent
     
 TextView
     android:layout_width=fill_parent
     android:layout_height=wrap_content
     android:text=@string/hello
     /
 /LinearLayout
 --

 package .DrawPoints;

 import android.app.Activity;
 import android.content.Context;
 import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.Paint;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnTouchListener;
 import android.widget.TextView;

 public class DrawPoints extends Activity implements OnTouchListener{
         static int i = 0;
         static float static_x = 0;
         static float static_y = 0;
         static float static_x1 = 0;
         static float static_y1 = 0;

     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
         View topLayout = this.findViewById(R.id.layout_id);
         // register for events for the view, previously
         topLayout.setOnTouchListener((OnTouchListener) this);

 }

   // the following callback is called when touch event on screen
 happens
         @Override
         public boolean onTouch(View v, MotionEvent event) {
                 String tag = null;

                 if(i == 0) {
                 static_x = event.getX();
                 static_y = event.getY();
                 i = 1;
                 } else
                 {
                         static_x1 = event.getX();
                         static_y1 = event.getY();

                 }
            // want to draw a line at this stage after figuring out two screen
 touches have been performed ??
                if(i == 1) {
                Paint p = new Paint();
                p.setColor(Color.WHITE);
            p.setStyle(Paint.Style.STROKE);
           Canvas canvas = new Canvas();
            canvas.drawColor(Color.BLUE);

            canvas.drawLine(static_x, static_y, static_x1, static_y1,
 p);
                 i = 0;
         }

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