[android-developers] Loading and Saving Settings to a file

2012-02-06 Thread John-Marc Desmarais
Hi,

I'm not sure what I'm doing wrong here:

I have an Override on onPause to save settings to a file and an
Override on onResume, and onCreate to load them back up from the file.

The onPause method looks like this:
@Override
public void onPause()
{
super.onPause();

// save configuration settings
if (cfg != null)
{
byte[] settingsBuffer = 
cfg.toSerializedBytes(getBaseContext());
Log.v(LogName.onPause, LogName.onPause + : settings 
Buffer :  +
settingsBuffer.length);
try
{
FileOutputStream fos = 
openFileOutput(settingsFile,
getBaseContext().MODE_WORLD_READABLE);
fos.write(settingsBuffer);
fos.getFD().sync();

fos.close();
}
catch (FileNotFoundException e)
{
Log.e(LogName.onPause, LogName.onPause + : 
File not found.  +
e.getMessage());
}
catch (IOException e)
{
Log.e(LogName.onPause, LogName.onPause + : IO 
Error.  + e.getMessage());
}
}
}

The load method looks like this:
public void loadSettings()
{
File inputFile = new File(settingsFile);
if (inputFile.exists())
{
byte[] settingsBuffer = new byte[(int) 
(inputFile.length())];
try
{
FileInputStream fis = 
openFileInput(settingsFile);
fis.read(settingsBuffer);
cfg = 
RXConfigurationSettings.fromSerializedBytes(settingsBuffer);
if (cfg != null)
{
cfg.populateTable((TableLayout)
findViewById(R.id.tableLayoutConfigurationSettingsTable),
getBaseContext());
}
fis.close();
}
catch (FileNotFoundException e)
{
Log.e(LogName.onResume, LogName.onResume + : 
File not found.  +
e.getMessage());
}
catch (IOException e)
{
Log.e(LogName.onResume, LogName.onResume + : 
IO Error.  + e.getMessage());
}
}
else
{
Log.e(LogName.className, Input FILE not found.);
}
}


The loadSettings is called from onCreate and onResume but I seem to
always hit the else condition and logcat always shows Input FILE not
found..

Can anyone provide insight into this problem?

Thanks
-jm

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


Re: [android-developers] Loading and Saving Settings to a file

2012-02-06 Thread John-Marc Desmarais
Hi,

Thank you for your reply. I have a couple follow up comments/questions
related to the responses. I have included these inline.

On Mon, Feb 6, 2012 at 12:25 PM, TreKing treking...@gmail.com wrote:
 On Mon, Feb 6, 2012 at 11:15 AM, John-Marc Desmarais j...@ieee.org wrote:

 I have an Override on onPause to save settings to a file


 Why not just use SharedPreferences?

I felt it would be quicker to serialize my class into a byte stream
than saving each configuration parameter separately and I couldn't
find the ability to store a byte stream using SharedPreferences.


 Can anyone provide insight into this problem?


 When you check the file existing, you use the raw file name, not relative
 to your data directory. Of course, that does not exist, as the file is
 relative to your data directory.

 Your subsequent call to openFileInput would likely succeed.

How do I handle the
byte[] settingsBuffer = new byte[(int) inputFile.length];
without opening a File?

i.e. How would I figure out in advance the size of the byte buffer I
need to receive my file? Or, what path can I append to my open file to
allow it to find the settingsFile, or is it not that easy?

-jm

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


Re: [android-developers] Loading and Saving Settings to a file

2012-02-06 Thread John-Marc Desmarais
On Mon, Feb 6, 2012 at 12:56 PM, TreKing treking...@gmail.com wrote:
 On Mon, Feb 6, 2012 at 11:36 AM, John-Marc Desmarais j...@ieee.org wrote:

 How do I handle the byte[] settingsBuffer = new byte[(int)
 inputFile.length]; without opening a File?


 You get the stream of data as the returned value of openFileInput. Then you
 can then read that into a byte array of the input's length. So your settings
 buffer would be initialized AFTER you open the input stream, using the
 stream's length.

Hi

Based on your first response I have tried the following:
public void onPause()
{
super.onPause();
// save configuration settings
SharedPreferences.Editor settingsEditor =
getSharedPreferences(settingsFile, 0).edit();
settingsEditor.putString(RXConfigurationSettings,
Base64.encodeToString(cfg.toSerializedBytes(getBaseContext()),
Base64.DEFAULT));
}

public void loadSettings()
{
SharedPreferences settings = getSharedPreferences(settingsFile, 
0);
if (settings.contains(RXConfiguration))
{
cfg = 
RXConfigurationSettings.fromSerializedBytes(Base64.decode(settings.getString(RXConfigurationSettings,
), Base64.DEFAULT));
}

else
{
Log.e(LogName.className, Input settings not found.);
}
}
And am now getting Input settings not found when closing and
reopening my application.

-jm

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


Re: [android-developers] Loading and Saving Settings to a file

2012-02-06 Thread John-Marc Desmarais
Yup.

commit() still works as advertised.

Thank you,
-jm

On Mon, Feb 6, 2012 at 1:19 PM, TreKing treking...@gmail.com wrote:
 On Mon, Feb 6, 2012 at 12:04 PM, John-Marc Desmarais j...@ieee.org wrote:

 And am now getting Input settings not found when closing and
 reopening my application.


 Read the class overview:
 http://developer.android.com/reference/android/content/SharedPreferences.Editor.html


 -
 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


Re: [android-developers] NullPointerException error

2012-02-03 Thread John-Marc Desmarais
On Tue, Jan 31, 2012 at 6:37 AM, geo geoandr...@gmail.com wrote:
 Hello,i am getting error:

 Caused by: java.lang.NullPointerException
 E/AndroidRuntime(329):  at ...LineGraph.getIntent(LineGraph.java:109)
 E/AndroidRuntime(329):  at LineGraph.onCreate(LineGraph.java:80)
 E/AndroidRuntime(329):  at
 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
 1047)
 E/AndroidRuntime(329):  at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
 2627)

  I have in one activity :

 double []myfinal=new double [100];

 Then,inside a function:

 public void compute(){
         ...
             //fill the points between
             for (int i=0;i=ttime;i++){
                myfinal[i]=init*Math.exp(-l*i);

             }
             Intent i=new Intent(this,calcs.class);
             ...
             i.putExtra(finals,myfinal);
             startActivity(i);
         }

 And in the other activity(LineGraph):
 ...
 private double [] myfinal=new double [100];

 public double []  getFinal(){ return this.myfinal;}
 public void setFinal(double [] myfinal){ this.myfinal=myfinal;}

 public void onCreate(Bundle savedInstanceState){
 ...
 double [] myfinal=extras.getDoubleArray(myfinal);
  setFinal(myfinal);

 public Intent getIntent(Context context){
 ...
  double []myfinal=getFinal();


 I am not sure if this is right double []
 myfinal=extras.getDoubleArray(myfinal);


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

It seems to me like the tag you are using to put your array into
extras is different from the tag you are using when retrieving it.

How about:
double [] myfinal=extras.getDoubleArray(finals);

-jm

-- 
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] Tethering two android phones

2012-02-02 Thread John-Marc Desmarais
Hi,

Does anyone know of a method to tether two phones via USB so that one
phone can communicate with the other using an intermediate PC?

Or, a method to change the default gateway given when tethering on one
of the phones from 192.168.42.129 to something else.

It seems that if I connect two android phones to the PC both are given
the same gateway address, it is possible to send/receive data from one
phone to the other? is there an address on the other side of the
gateway address that can be used? Can I configure the address on one
of the phones so that the gateway addresses are unique?

Thanks,
John-Marc Desmarais

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


Re: [android-developers] VideoView and buffering

2012-01-31 Thread John-Marc Desmarais
Hi,

I'm using the reset() now. There's a little bump in the playback every
time it reaches the end of the content that existed in the file when
it was initially loaded which I don't like but I'm using prepareAsync
so I think this hiccup is as small as I can make it with a single
VideoView.

Thanks for your help.
-jm


On Mon, Jan 30, 2012 at 11:16 AM, Daniel Drozdzewski
daniel.drozdzew...@gmail.com wrote:
 John-Marc,

 I have not done this myself, but here is tutorial on how to do it:
 http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/

 They actually create new MediaPlayer object upon every update to the
 buffer file and point this new MediaPlayer to the updated buffer every
 single time.

 I would test calling MediaPlayer.reset() first instead of creating new
 player object every time, to see whether time and memory consumed by
 such solution is a bit better.

 HTH,

 Daniel





 On 30 January 2012 15:49, John-Marc Desmarais j...@ieee.org wrote:
 Hi,

 I am currently writing a video file to the SDCard while playing it
 with VideoView.

 My problem is that, if I buffer 1MB of video and begin the Video
 playback, the video stops after 1MB has been played, even though by
 this time, 5MBs of file has now been written to the sdcard.

 I have been trying various things in onCompletion handler.. such as:
                int curLoc = mp.getCurrentPosition();
                Log.e(LogName.onCompletion, LogName.onCompletion + 
 CurrentLocation:
  + mp.getCurrentPosition());
                Log.e(LogName.onCompletion, LogName.onCompletion + Duration: 
  +
 mp.getDuration());
                mp.pause();
                mp.prepareAsync();
                mp.start();
                mp.seekTo(curLoc);

 In this case I get a Cannot play video message.

 Or:
                int curLoc = mp.getCurrentPosition();
                Log.e(LogName.onCompletion, LogName.onCompletion + 
 CurrentLocation:
  + mp.getCurrentPosition());
                Log.e(LogName.onCompletion, LogName.onCompletion + Duration: 
  +
 mp.getDuration());
                mp.prepareAsync();
                mp.start();
                mp.seekTo(curLoc);

 This crashes with prepare Async in State 128.

 Has anyone solved the problem of re-queuing file in the videoView so
 that it plays everything that has been written to the sdcard even
 though it starts with a smaller file?

 Regards,
 -jm

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



 --
 Daniel Drozdzewski

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


Re: [android-developers] VideoView and buffering

2012-01-31 Thread John-Marc Desmarais
Daniel,

It is my feeling that since the swap is being done in the onCompletion
handler, there would be a gap in playback in either case. If prepare
is the time consuming part of Prepare(), Start(), Seekto().. then I
can see this shrinking the gap. But, if there is a detectable delay,
then the length of this delay is of lesser concern. If I get the time
to go back to this component when I'm done some other bits, I'll let
you know how it turns out.

I find it odd that the VideoView screen doesn't ever re-read from the
file. I've tried buffering 1MB or 2MB before starting to play, but it
still doesn't go back to the file to read more data, I'm guessing it
loads all 2MB into memory before starting to play. I'll try some
bigger buffer sizes as well to see if I can force it to reread before
the video runs out.

-jm

On Tue, Jan 31, 2012 at 11:08 AM, Daniel Drozdzewski
daniel.drozdzew...@gmail.com wrote:
 John-Marc,

 I am glad that it works.

 I am not sure whether prepareAsync would be quicker than blocking prepare 
 call.

 I mean that whatever the system implementation of the player,
 preparing it takes the same amount of time and async call simply does
 not block, but if you call play as a next statement after
 prepareAsync, I think playing will be put on hold until the player is
 ready to play. You could test both approaches by adding some logging
 and swapping these calls to prepare.

 I was also thinking that you could create 2 MediaPlayer objects and
 the one that is not playing at the moment is being prepared in the
 background with the new data that arrived.
 In MediaPlayer.OnCompletionListener of the first player you simply
 cause the background, prepared player to swap seats with the one that
 just finished. Maybe that would be a bit smoother... ( I am only
 speculating here). This is simple double buffering used all over
 computers to avoid flickering when displaying moving objects.

 Not the easiest approach, but if you are swapping the files from
 underneath 1 player, then swapping players from underneath 1 activity
 should not be much more complex.

 Daniel







 On 31 January 2012 14:50, John-Marc Desmarais j...@ieee.org wrote:
 Hi,

 I'm using the reset() now. There's a little bump in the playback every
 time it reaches the end of the content that existed in the file when
 it was initially loaded which I don't like but I'm using prepareAsync
 so I think this hiccup is as small as I can make it with a single
 VideoView.

 Thanks for your help.
 -jm


 On Mon, Jan 30, 2012 at 11:16 AM, Daniel Drozdzewski
 daniel.drozdzew...@gmail.com wrote:
 John-Marc,

 I have not done this myself, but here is tutorial on how to do it:
 http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/

 They actually create new MediaPlayer object upon every update to the
 buffer file and point this new MediaPlayer to the updated buffer every
 single time.

 I would test calling MediaPlayer.reset() first instead of creating new
 player object every time, to see whether time and memory consumed by
 such solution is a bit better.

 HTH,

 Daniel





 On 30 January 2012 15:49, John-Marc Desmarais j...@ieee.org wrote:
 Hi,

 I am currently writing a video file to the SDCard while playing it
 with VideoView.

 My problem is that, if I buffer 1MB of video and begin the Video
 playback, the video stops after 1MB has been played, even though by
 this time, 5MBs of file has now been written to the sdcard.

 I have been trying various things in onCompletion handler.. such as:
                int curLoc = mp.getCurrentPosition();
                Log.e(LogName.onCompletion, LogName.onCompletion + 
 CurrentLocation:
  + mp.getCurrentPosition());
                Log.e(LogName.onCompletion, LogName.onCompletion + 
 Duration:  +
 mp.getDuration());
                mp.pause();
                mp.prepareAsync();
                mp.start();
                mp.seekTo(curLoc);

 In this case I get a Cannot play video message.

 Or:
                int curLoc = mp.getCurrentPosition();
                Log.e(LogName.onCompletion, LogName.onCompletion + 
 CurrentLocation:
  + mp.getCurrentPosition());
                Log.e(LogName.onCompletion, LogName.onCompletion + 
 Duration:  +
 mp.getDuration());
                mp.prepareAsync();
                mp.start();
                mp.seekTo(curLoc);

 This crashes with prepare Async in State 128.

 Has anyone solved the problem of re-queuing file in the videoView so
 that it plays everything that has been written to the sdcard even
 though it starts with a smaller file?

 Regards,
 -jm

 --
 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] VideoView and buffering

2012-01-30 Thread John-Marc Desmarais
Hi,

I am currently writing a video file to the SDCard while playing it
with VideoView.

My problem is that, if I buffer 1MB of video and begin the Video
playback, the video stops after 1MB has been played, even though by
this time, 5MBs of file has now been written to the sdcard.

I have been trying various things in onCompletion handler.. such as:
int curLoc = mp.getCurrentPosition();
Log.e(LogName.onCompletion, LogName.onCompletion + 
CurrentLocation:
 + mp.getCurrentPosition());
Log.e(LogName.onCompletion, LogName.onCompletion + Duration:  
+
mp.getDuration());
mp.pause();
mp.prepareAsync();
mp.start();
mp.seekTo(curLoc);

In this case I get a Cannot play video message.

Or:
int curLoc = mp.getCurrentPosition();
Log.e(LogName.onCompletion, LogName.onCompletion + 
CurrentLocation:
 + mp.getCurrentPosition());
Log.e(LogName.onCompletion, LogName.onCompletion + Duration:  
+
mp.getDuration());
mp.prepareAsync();
mp.start();
mp.seekTo(curLoc);

This crashes with prepare Async in State 128.

Has anyone solved the problem of re-queuing file in the videoView so
that it plays everything that has been written to the sdcard even
though it starts with a smaller file?

Regards,
-jm

-- 
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] VideoView.setLayoutParams - ClassCastException

2012-01-25 Thread John-Marc Desmarais
Hi,

I have a VideoView in a LinearLayout with 2 other boxes. In trying to
create a full screen video, I am doing the following:

private boolean isFullScreen = false;
public void onClick(View v)
{
VideoView vv = (VideoView) v.findViewById(R.id.videoView1);
LinearLayout.LayoutParams lp =
(LinearLayout.LayoutParams)vv.getLayoutParams();
if (isFullScreen)
{
isFullScreen = false;
lp.weight = 0.2f;
vv.setLayoutParams(lp);
v.invalidate();
}
else
{
isFullScreen = true;
lp.weight = 0f;
vv.setLayoutParams(lp);
v.invalidate();
}
Log.v(LogName.onClick, Video switch to  + (isFullScreen ? 
Full
screen : Normal size));
}

I am getting an exception:
01-26 04:12:20.380: E/AndroidRuntime(8010): FATAL EXCEPTION: main
01-26 04:12:20.380: E/AndroidRuntime(8010):
java.lang.ClassCastException:
android.widget.RelativeLayout$LayoutParams
01-26 04:12:20.380: E/AndroidRuntime(8010): at
com.elliptictech.hdcprx.gui.PlayVideo.onClick(PlayVideo.java:54)
01-26 04:12:20.380: E/AndroidRuntime(8010): at
android.view.View.performClick(View.java:2538)
01-26 04:12:20.380: E/AndroidRuntime(8010): at
android.view.View$PerformClick.run(View.java:9152)
01-26 04:12:20.380: E/AndroidRuntime(8010): at
android.os.Handler.handleCallback(Handler.java:587)
01-26 04:12:20.380: E/AndroidRuntime(8010): at
android.os.Handler.dispatchMessage(Handler.java:92)
01-26 04:12:20.380: E/AndroidRuntime(8010): at
android.os.Looper.loop(Looper.java:130)
01-26 04:12:20.380: E/AndroidRuntime(8010): at
android.app.ActivityThread.main(ActivityThread.java:3691)
01-26 04:12:20.380: E/AndroidRuntime(8010): at
java.lang.reflect.Method.invokeNative(Native Method)
01-26 04:12:20.380: E/AndroidRuntime(8010): at
java.lang.reflect.Method.invoke(Method.java:507)
01-26 04:12:20.380: E/AndroidRuntime(8010): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
01-26 04:12:20.380: E/AndroidRuntime(8010): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)

Can anyone suggest why this is the case? Alternatively, can you
suggest another method to set the video view to full screen?

Best regards,
-jm

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


Re: [android-developers] VideoView.setLayoutParams - ClassCastException

2012-01-25 Thread John-Marc Desmarais
That is a very good point.
Thanks.
-jm

On Wed, Jan 25, 2012 at 2:33 PM, TreKing treking...@gmail.com wrote:
 On Wed, Jan 25, 2012 at 1:25 PM, John-Marc Desmarais j...@ieee.org wrote:

 Can anyone suggest why this is the case?


 This is your code: (LinearLayout.LayoutParams)vv.getLayoutParams();

 This is the stack trace:
 java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams

 -
 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] AsyncTask never calls onProgressUpdate

2012-01-16 Thread John-Marc Desmarais
Hi,

I have the following AsynchTask class but, it fails to execute the
onProgressUpdate method when doInBackground is running. That is to say
the Log.v(LogName.onProgressUpdate, LogName.onProgressUpdate) never
occurs in LogCat. There are two calls to publishProgress. The first is
after the authentication text view is copied to the instance variable
and second in the update thread.

Can anyone offer insight?

public class AuthenticateTask extends AsyncTaskDialog, Void, Boolean
{

private int num_dots;
private boolean firstRun;
private String textToUpdate;
TextView textViewAuthenticating;
Dialog dialog;

private class LogName
{
public static final String className = AuthenticateTask;
public static final String onPreExecute = className + 
.onPreExecute():;
public static final String doInBackground = className +
.doInBackground(Dialog...):;
public static final String onProgressUpdate = className +
.onProgressUpdate():;
public static final String onPostExecute = className +
.onPostExecute(Boolean):;
}

protected void onPreExecute()
{
Log.v(LogName.onPreExecute, LogName.onPreExecute);
num_dots = 0;
firstRun = true;
}

@Override
protected Boolean doInBackground(Dialog... params)
{
Log.v(LogName.doInBackground, LogName.doInBackground);
dialog = params[0];
textViewAuthenticating = (TextView)
dialog.findViewById(R.id.TextViewAuthentication);
publishProgress();
Log.v(LogName.doInBackground, LogName.doInBackground + dialog: 
 + dialog);

Thread updaterThread = new Thread(new Runnable()
{

public void run()
{
// TODO Auto-generated method stub
try
{
Thread.sleep(250);
}
catch (InterruptedException e)
{
}
finally
{
AuthenticateTask.this.publishProgress();
}
}

});

updaterThread.start();
if (Authenticate())
{
return true;
}
return false;
}

protected void onProgressUpdate()
{
Log.v(LogName.onProgressUpdate, LogName.onProgressUpdate);
String tmpString;
dialog.setContentView(R.layout.connnection_progess_dialog);

if (firstRun)
{
Log.v(LogName.onProgressUpdate, 
LogName.onProgressUpdate + First Run);
textToUpdate = 
textViewAuthenticating.getText().toString();
Log.v(LogName.onProgressUpdate, 
LogName.onProgressUpdate +
textToUpdate =  + textToUpdate);
firstRun = false;
}
if (num_dots++ == 5)
{
num_dots = 0;
}
tmpString = textToUpdate;
for (int i = 0; i  num_dots; i++)
{
tmpString +=  .;
}
Log.v(LogName.onProgressUpdate, LogName.onProgressUpdate +
tmpString =  + tmpString);
textViewAuthenticating.setText(tmpString);
}
protected void onPostExecute(Boolean result)
{
Log.v(LogName.onPostExecute, LogName.onPostExecute);
String authentication_finished =
dialog.getContext().getResources().getString(R.string.authentication_finished);
Log.v(LogName.onPostExecute, LogName.onPostExecute + 
authentication_finished);
textViewAuthenticating.setText(authentication_finished);

textViewAuthenticating.setCompoundDrawables(dialog.getContext().getResources().getDrawable(R.drawable.checkmark),
null, null, null);
firstRun = true;
}

}


Regards,
-jm

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


Re: [android-developers] Re: AsyncTask never calls onProgressUpdate

2012-01-16 Thread John-Marc Desmarais
Hi,

The authenticate method takes a long time, and I want to update
progress while that's happening like this:

Authenticating .
Authenticating . .
Authenticating . . .
Authenticating . . . .
Authenticating

So I created a thread to add a dot to my TextView every 1/4 second.

Mark Murphy's solution seems to be functioning properly. My error was
assuming that
protected void onProgressUpdate() was equivalent to
protected void onProgressUpdate(Void... voids)
as well as missing some @Overrides.

Thanks all,
-jm


On Mon, Jan 16, 2012 at 2:24 PM, Streets Of Boston
flyingdutc...@gmail.com wrote:
 Why are you starting yet another thread in doInBackground()?
 The method doInBackground is already called in a separate (background)
 thread. No need to yet spawn another one.

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


Re: [android-developers] Re: AsyncTask never calls onProgressUpdate

2012-01-16 Thread John-Marc Desmarais
How do I pass my Dialog to onPreExecute?

-jm

2012/1/16 Kostya Vasilyev kmans...@gmail.com:
 ... and this:

 textViewAuthenticating = (TextView)
 dialog.findViewById(R.id.TextViewAuthentication);

 belongs in onPreExecute, or elsewhere on the UI thread, *not* in 
 doInBackground.

 16 января 2012 г. 23:24 пользователь Streets Of Boston
 flyingdutc...@gmail.com написал:
 Why are you starting yet another thread in doInBackground()?
 The method doInBackground is already called in a separate (background)
 thread. No need to yet spawn another one.

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

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


Re: [android-developers] Re: Giving away my book: Genius Android Marketing

2012-01-10 Thread John-Marc Desmarais
I'll play.

Sign me up.
-jm

On Mon, Jan 9, 2012 at 3:45 PM, YuviDroid yuvidr...@gmail.com wrote:
 Looks very interesting! Count me in!  :)

 Yuvi


 On Mon, Jan 9, 2012 at 6:04 PM, PhotoSteve dfwgoph...@gmail.com wrote:

 Add me too...I'm so new to Android I don't even know what I don't know
 even to ask questions or how to phrase them right for you nice people
 to understand what I'm asking. Any help for the noob is great.

 Steve

 On Jan 5, 10:50 am, scp89 jayvanbui...@gmail.com wrote:
  I've recently finished writing the first full-length, android-specific
  book on Android Marketing. It covers tips, tricks, strategies,
  competitive analysis, and so much more. Everything I've learned in 2
  years selling android apps, I've put into this book. It is available
  via e-book OR softcover:
 
 
  E-book:http://www.amazon.com/Genius-Android-Marketing-Outsmarting-ebook/dp/B...
 
 
  Softcover:http://www.amazon.com/Genius-Android-Marketing-Outsmarting-Market/dp/...
 
  GIVEAWAY: I am giving away 3 PDF copies of the book to readers! Simply
  reply to this thread, and 1 week from today I will randomly select 3
  members and PM you a link to your free download of the 130 page book.

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




 --
 YuviDroid
 Check out Launch-X (a widget to quickly access your favorite apps and
 contacts!)
 http://android.yuvalsharon.net

 --
 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] Add Native Support not found in Eclipse

2012-01-10 Thread John-Marc Desmarais
Hi,

Can anyone help getting Android Tools - Add Native Support to show up
in Eclipse?

Eclipse Version:
Eclipse IDE for C/C++ Developers

Version: Indigo Service Release 1
Build id: 20110916-0149

My system path includes
C:\Android\android-ndk-r7

Running Windows 7.

I have no problems building Android apps, but I want to add some native support.

Regards,
-jm

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


Re: [android-developers] Re: Add Native Support not found in Eclipse

2012-01-10 Thread John-Marc Desmarais
Hi,

Thanks for your help. I installed Sequoya and MTJ but, I still have no
Add Native Support under Android Tools.

I have also tried installing android-ndk-r6b and having
C:\android\android-ndk-r6b in the path. But, currently, I have
C:\android\android-ndk-r7 installed and in the system path.

Maybe Indigo is the problem. I'll try Helios.
-jm

On Tue, Jan 10, 2012 at 5:05 PM, Fred Grott fred.gr...@gmail.com wrote:
 do not ask how I know this but I believe the CDT native for android stuff is
 under the Eclipse MTJ project so you have to install that stuff and it also
 has Sequoya for android as well..w2hich includes a localization tool

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