running android application

by siddarth » Sat, 27 Feb 2010 16:28:29 GMT


Sponsored Links
 hi...

I have complete code of an android application running well .
But this application will run only on clicking its icon in the menu

I WANT THIS APPLICATION TO RUN WHEN " 5 " BUTTON ON THE ANDROID
KEYBOARD IS CONTINUOUSLY PRESSED  FOR MORE THAN 5sec

How do i do it..... Plz... help me its urgent


Thanking You in Advance
sid

--



Other Threads

1. Can anyone hook me up with an Exchange email account that I could use for testing?

Hi,
   I'm putting together a lightweight email provider for use with one
of my apps (based on the K9 mail client).  I'd love to test it with an
Exchange account before releasing it.

   I'm hoping that some kind sole out there will be able to hook me up
with an Exchange account that I can use for testing.

Thanks a bunch!

Steve

-- 

2. Control a graphic with android buttons

Hello,

at the moment I'm not that much familiar with Android and I try to
teach it myself. My target is it to control a graphic with android
buttons, so at first I designed the layout:

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout android:id="@+id/FrameLayout01"
                     android:layout_width="fill_parent"
                     android:layout_height="fill_parent"
                     xmlns:android="http://schemas.android.com/apk/res/android">

                <TableLayout
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:gravity="bottom"
                        android:stretchColumns="*"
                        android:layout_alignParentBottom="true">
                        <TableRow>
                    <Button
                        android:id="@+id/btnUp"
                        android:layout_width="80px"
                        android:layout_height="wrap_content"
                        android:text="Up"

                        />
                    <Button
                        android:id="@+id/btnEnter"
                        android:layout_width="70px"
                        android:layout_height="wrap_content"
                        android:text="Enter"
                        />
                    <Button
                        android:id="@+id/btnDown"
                        android:layout_width="80px"
                        android:layout_height="wrap_content"
                        android:text="Down"
                        />
                    </TableRow>
        </TableLayout>
</FrameLayout>

This seems to be what I want. Then I created a view and a thread:
--------------------------------------------
package my.domain.test;

public class GameThread extends Thread {
    private SurfaceHolder surfaceHolder;
    private GamePanelView gamePanel;
    private boolean run = false;

    public GameThread(SurfaceHolder surfaceHolder, GamePanelView
panel) {
        this.surfaceHolder = surfaceHolder;
        this.gamePanel = panel;
    }

    public void setRunning(boolean run) {
        this.run = run;
    }

    @Override
    public void run() {
        Canvas c;
        while (run) {
            c = null;
            try {
                c = surfaceHolder.lockCanvas(null);
                synchronized (surfaceHolder) {
                        gamePanel.updatePosition();
                    gamePanel.onDraw(c);
                }
            } finally {
                if (c != null) {
                    surfaceHolder.unlockCanvasAndPost(c);
                }
            }
        }
    }
}
-----------------------------
package my.domain.test;

public class GamePanelView extends SurfaceView implements Callback {

        private GameThread thread;
        private Bitmap ball;
        private int posX = 10, posY = 10;

        public GamePanelView(Context context, AttributeSet attrs)  {
                super(context, attrs);
                getHolder().addCallback(this);
                thread = new GameThread(getHolder(), this);
                createImages();
        }

        @Override
        public void surfaceChanged(SurfaceHolder holder, int format, int
width, int height) {
                // TODO Auto-generated method stub

        }

        @Override
        public void surfaceCreated(SurfaceHolder holder) {
                thread.setRunning(true);
                thread.start();
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {
        boolean retry = true;
        thread.setRunning(false);
        while (retry) {
            try {
                thread.join();
                retry = false;
            } catch (InterruptedException e) {
                //
            }
        }
        }

    @Override
    public void onDraw(Canvas canvas) {
        canvas.drawColor(Color.BLACK);
        canvas.drawBitmap(ball, posX, posY, null);
    }

    public GameThread getThread()  {
        return thread;
    }

    private void createImages()   {
        ball = BitmapFactory.decodeResource(getResources(),
R.drawable.ball);
    }

    public void updatePosition()  {
        //update Position
    }

}
---------------------------

Drawing the ball itself works and drawing the buttons itself works,
but I neighter know how to combine that nor I know how to listen to
these buttons (it's probably not onKeyDown, because I used this for
the d-pad). In earlier examples, I just used this xml as my main.xml:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/
android"
        android:background="#000000"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <my.domain.test
      android:id="@+id/game"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"/>

</FrameLayout>

I can additionally define this in my previous xml file. This seems to
work too, no exceptions. But what do I have to do when I want to draw
graphics and those android buttons I defined in the xml file at the
same time? And what is the best approach to control the graphic with
those buttons? I hope that anybody can give my some useful hints.

Best Regards.


-- 

3. external input device

4. Programmatically setting a new default ringtone without the ringtone picker

5. Setting new default ringtone without using RingtonePicker?

6. Launch Activity from BroadcastReciever

7. Maths behind the Android orientation calculation algorithm