[android-developers] to move an image view along a bezier curve

2011-11-01 Thread ruchira
I have drawn a bezier curve and I want my imageview which is a picture
of a ball to follow the path traced by the curve and eventually fall
to the ground.How do I do that? Please 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] why my translate animation is not working??

2011-10-21 Thread ruchira
I am trying to apply translate animation to an imageview but it is not
working.Plz help


@Override
public void onDraw(Canvas canvas) {

  Log.w(this.getClass().getName(),onDraw of Balls called);

  BallsOnDraw(canvas);

}

 void BallsOnDraw(Canvas canvas)
 {

canvas.drawLine(0, 240, 160, 0, mPaint);
canvas.drawLine(160, 0, 320, 240, mPaint);

TranslateAnimation mTrans = new TranslateAnimation(0, 320,
0,240);

mTrans.setDuration(6000);
SitoliaActivity.mBal.startAnimation(mTrans);


 }

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


[android-developers] how does the co-ordinate system of android work?

2011-10-18 Thread ruchira
I am trying to implement a projectile motion by plotting the points on
the screen of my app.I need to scale the calculated co-ordinates and
at the same time I also need to know the range of X-Y co-ordinates
visible on my screen so that my final calculated co-ordinates fits on
visible screen

How do I found the range of screen co-ordinates?

-- 
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] timer for implementing projectile motion

2011-10-16 Thread ruchira
Can anyone please suggest me the type of android's predefined  timer
to be used for implementing projectile motion or do I need to write a
custom timer.Also please let me know  the range of initial velocity V
which can be used for assumption.

-- 
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] ondraw method for a view getting called again and again

2011-09-28 Thread ruchira
I have overriden ondraw method for a view where I am drawing a
circle.But this method is getting called again and again though I
don't have any loop and nor have I called Invalidate().. Any
suggestions please??

-- 
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] surface view inside horizontal scroll view

2011-09-28 Thread ruchira
I want to have a surface view or view class inside a horizontal scroll
view but looks like surfacecreated or ondraw method is not called
inside a horizontal scroll view.Please suggest me some alternate
design keeping in mind that Having a horizontal scroll view is a must
for my app

-- 
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: ondraw method for a view getting called again and again

2011-09-28 Thread ruchira
1) Here is the main activity class form where i get the handle to the
view from xml:-

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.main);


mGameStart = true;




// get handles to the Balls from XML, and its Thread


mBalls = (Balls) findViewById(R.id.balls);



2) here is the view class
public class Balls extends View{

private static final String TAG = BallsView;

private int mMode = READY;
public static final int PAUSE = 0;
public static final int READY = 1;
public static final int RUNNING = 2;
public static final int LOSE = 3;

private final Paint mPaint = new Paint();

public Balls(Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
setFocusable(true);
setWillNotDraw(false);


}
public Balls(Context context, AttributeSet attrs) {
super(context, attrs);
 setFocusable(true);
 setWillNotDraw(false);
}

 @Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
Log.w(this.getClass().getName(),Just before circle draw);

canvas.drawCircle(100, 150, 5,mPaint);

}


On Sep 28, 1:56 pm, TreKing treking...@gmail.com wrote:
 On Wed, Sep 28, 2011 at 12:23 PM, ruchira ruchira...@gmail.com wrote:
  Any suggestions please??

 Post some code?

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

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


[android-developers] Re: When is onSurfaceCreated called??

2011-09-22 Thread ruchira
I did the same but it is not working!!!

On Sep 21, 9:10 pm, kdı gjofd android.develope...@gmail.com wrote:
 You can integrate it from main.xml ..Create area for Surfaceview and
 describe for your app..
 Link by findViewById(R.id.surfaceview)  and use it..

 2011/9/21, ruchira ruchira...@gmail.com:







  I am asking this question as I have been stuck with this issue for
  almost a month that the surface created function of my app is never
  called and I am stuck with it!!!

  --
  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] When is onSurfaceCreated called??

2011-09-21 Thread ruchira
I am asking this question as I have been stuck with this issue for
almost a month that the surface created function of my app is never
called and I am stuck with it!!!

-- 
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] accessing media player declared in a service from my main activity

2011-09-15 Thread ruchira
I am a newbie to android development.I am trying to put background
music for my app.I used intent service wherein  I declared media
player and from my main activity the service was called by explicit
intent.

Though the media player plays the music file but I am stuck with
following issues:-

1)I want to pause the music when the app has lost focus for eg. user
pressing back button to goto some previous app.But how do i pause the
media player which is inside a service.

I know that from my main activity's OnPause lifecycle method I should
make a call to pause the player.. but how do I achieve that?? Do I
have to bind the service to the activity or what should I do??

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


[android-developers] Media Player stops abruptly with a warning in logcat: TimedEventQueue(33): Event 4 was not found in the queue, already cancelled?

2011-09-14 Thread ruchira
I am trying to put background music in my app.I have created an intent
service which creates a Media Player and starts the music.

Once my app is launched the music is played only for a second and
after that I see the following warning in my logcat:-

09-13 20:12:54.082: WARN/TimedEventQueue(33): Event 4 was not found in
the queue, already cancelled?

For every run of my App, the Event number changes.This time it was
Event 5.

Here is my service class which implements media player:-

import android.app.IntentService;
import android.content.Intent;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnErrorListener;
import android.widget.Toast;

public class MusicService extends IntentService {

MediaPlayer mPlayer;
private OnErrorListener mErrorListener;

public MusicService() {
super(MusicService);
// TODO Auto-generated constructor stub
}

@Override
protected void onHandleIntent(Intent intent) {
// TODO Auto-generated method stub
  // Normally we would do some work here, like download a
file.


}

///

@Override
public int onStartCommand (Intent intent, int flags, int startId)

{
Toast.makeText(this, service starting,
Toast.LENGTH_SHORT).show();
mPlayer.setLooping(true);
mPlayer.start();

return super.onStartCommand(intent,flags,startId);


}

@Override

public void onCreate ()

{
super.onCreate();
  //  try{
mPlayer = MediaPlayer.create(this, R.raw.jingle);
//}catch (IllegalArgumentException e) {
//e.printStackTrace();
//}catch (IllegalStateException e ) {
//e.printStackTrace();
//}

if(mPlayer!= null)
{
mPlayer.setLooping(true); // Set looping
mPlayer.setVolume(100,100);
}


mPlayer.setOnErrorListener(new OnErrorListener() {

public boolean onError(MediaPlayer mp, int what, int extra) {
// TODO Auto-generated method stub
onPlayError();
return true;
}

});


}

private void onPlayError() {
Toast.makeText(this, music player failed,
Toast.LENGTH_SHORT).show();
if(mPlayer != null)
{
try{
mPlayer.stop();
mPlayer.release();
}finally {
mPlayer = null;
}
}
}

@Override
public void onDestroy ()

{
super.onDestroy();
if(mPlayer != null)
{
try{
mPlayer.stop();
mPlayer.release();
}finally {
mPlayer = null;
}
}

}



}

-- 
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] Surface Created never called and so the thread never runs?

2011-09-12 Thread ruchira
I have been struggling with this issue since a long time.I am a newbie
to android. I have done all the homework and gone through all the
topics related to my issues but it did not help.

My app code is based on lunar lander with modifications. I have got a
splash screen which then displays a menu screen which launches my main
activity.

In my App, I have a class Game which I have declared in the main.xml
as follows:-

I am pasting the portion of the xml file:-

?xml version=1.0 encoding=utf-8?
HorizontalScrollView xmlns:android=http://schemas.android.com/apk/
res/android
android:orientation=horizontal
android:layout_width=match_parent
android:layout_height=match_parent


RelativeLayout
android:orientation=horizontal
android:layout_width=match_parent
android:layout_height=match_parent
android:background=@drawable/desert
android:clipToPadding=true

 com.example.android.Game
  android:id=@+id/Game
  android:layout_width=fill_parent
  android:layout_height=fill_parent/
I am trying to inflate this activity from my app's MainActivity as
follows:-

Unlike lunar lander my thread is seperate class from the Main
activity.

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);

mGame = (Game) findViewById(R.id.Game);
mGameThread = mGame.getThread();
I have created a thread the definition of which is in a seperate file
but but which is declared as part of Game class..

The problem I am facing is that the surfacecreated for my Game class
is never called.So the thread never runs.

Below I am pasting the Game Class

public class Game extends SurfaceView implements
SurfaceHolder.Callback{

 private int mX;
 private int mY;
 private int mSpeedX;
 private int mSpeedY;
 private Bitmap mBitmap;

 private GameThread thread;

 public static Context mContext;

 private TextView mStatusText;

 private boolean mSurfaceExists;

 public Game(Context context)
 {
 super(context);
   SurfaceHolder holder = getHolder();
 holder.addCallback(this);

 // create thread only; it's started in surfaceCreated()
 Log.w(this.getClass().getName(),Before thread create);
 thread = new GameThread(holder, context, new Handler() {

 @Override
 public void handleMessage(Message m) {
 Log.w(this.getClass().getName(),In Handle message);
 
mStatusText.setVisibility(m.getData().getInt(viz));
 
mStatusText.setText(m.getData().getString(text));
}


 });

 setFocusable(true); // make sure we get key events

 }

 public Game(Context context, AttributeSet attrs, int defStyle) {
 super(context, attrs, defStyle);
 SurfaceHolder holder = getHolder();
 holder.addCallback(this);

 // create thread only; it's started in surfaceCreated()
 Log.w(this.getClass().getName(),Before thread create);
 thread = new GameThread(holder, context, new Handler() {

 @Override
 public void handleMessage(Message m) {
 Log.w(this.getClass().getName(),In Handle message);
 
mStatusText.setVisibility(m.getData().getInt(viz));
 
mStatusText.setText(m.getData().getString(text));
}


 });

 setFocusable(true); // make sure we get key events

 }

 public Game(Context context, AttributeSet attrs) {
 super(context, attrs);
 // register our interest in hearing about changes to our
surface
 SurfaceHolder holder = getHolder();
 holder.addCallback(this);

 // create thread only; it's started in surfaceCreated()
 Log.w(this.getClass().getName(),Before thread create);
 thread = new GameThread(holder, context, new Handler() {

 @Override
 public void handleMessage(Message m) {
 Log.w(this.getClass().getName(),In Handle message);
 
mStatusText.setVisibility(m.getData().getInt(viz));
 
mStatusText.setText(m.getData().getString(text));
}


 });

 setFocusable(true); // make sure we get key events

 }


 /**
 * Fetches the animation thread corresponding to this
LunarView.
 *
 * @return the animation thread
 */
public GameThread getThread() {
return thread;
}



/**
 * Standard window-focus override. Notice focus lost so we can
pause on
 * focus lost. e.g. user switches to take a call.
 */
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
if (!hasWindowFocus) thread.pause();
}

/**
 * Installs a pointer to the text view used for messages.
 */
public void setTextView(TextView textView) {