dispatchTouchEvent

by Business Talk » Sat, 09 Jan 2010 02:15:29 GMT


Sponsored Links
 How can I programmatically press/release a button? I was playing with
the button.dispatchTouchEvent(motionEvent); but failed to
programmatically generate  the MotionEvent to be passed to the
dispatchTouchEvent



dispatchTouchEvent

by Business Talk » Sat, 09 Jan 2010 02:37:37 GMT


 I found the way to generate the MotionEvent, and it's
MotionEvent.obtain



> dispatchTouchEvent


Sponsored Links


dispatchTouchEvent

by jbo » Wed, 27 Jan 2010 04:28:07 GMT


 i , i have a qustion about onTouch event, I have a layout that
consist of 2 elements, a WebView and on top of it a TextView and then
a custom view, that expand all over the screen and is transparent.
With these i want to carch touch events and delegate to the correct
widget either TextView or WebView depending on the touch event
position (MoseEvent).

[code]
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TextView
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Type here:"/>

<WebView android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/label"/>

</RelativeLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<com.frame.TransparentPanel android:id="@+id/transparent_panel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>

</LinearLayout>

</FrameLayout>
[/code]


[code]
public class TransparentPanel extends LinearLayout
{
private Paint innerPaint, borderPaint ;
private List<PointF> pointsToDraw = new ArrayList<PointF>();
private WebView webview;
private Paint touchPaint;

public TransparentPanel(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}

public TransparentPanel(Context context) {
super(context);
init();
}

private void init() {
touchPaint = new Paint();
touchPaint.setARGB(255, 0, 0, 255);
touchPaint .setAntiAlias(true);
touchPaint .setStyle(Style.STROKE);
touchPaint .setStrokeWidth(2);

innerPaint = new Paint();
innerPaint.setARGB(0, 100, 75, 75); //gray
innerPaint.setAntiAlias(true);

borderPaint = new Paint();
borderPaint.setARGB(255, 255, 255, 255);
borderPaint.setAntiAlias(true);
borderPaint.setStyle(Style.STROKE);
borderPaint.setStrokeWidth(2);
}

public void setInnerPaint(Paint innerPaint) {
this.innerPaint = innerPaint;
}

public void setBorderPaint(Paint borderPaint) {
this.borderPaint = borderPaint;
}

@Override
public boolean onTouchEvent(MotionEvent



Other Threads

1. Default Buttons appearing as black rectangles on DROIDX?

Hopefully someone can point me in the right direction as to what is
going on here:

In my app, I use standard buttons and spinners, which have always
appeared as basic beveled silver buttons.  I have seen these look fine
on my Nexus One running 2.2.1 as well as a couple of other phones.

I just saw a friend's brand new DROIDX running 2.2.1, and when viewing
my app on that device all the buttons and spinners are ugly black
rectangles that look horrible and ruin the layout.

Any ideas on what is going on here?

This is an example of the standard buttons and spinners I am talking
about:

<Button android:text="Previous"
        android:id="@+id/previousresults"
        android:layout_width="fill_parent"
       android:layout_height="wrap_content">
</Button>

<Spinner android:id="@+id/mySpinner"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:drawSelectorOnTop="true"
                android:prompt="@string/myPrompt"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:paddingTop="2dip"
                android:paddingBottom="2dip">
</Spinner>

-- 

2. Voice search/Record Error

Hi,

I am new to Audio module and new to Android.
I am getting the following error when I start "Voice Search"
application.

#########################
W/InputManagerService(  965): Window already focused, ignoring focus
gain of: com.android.internal.view.IInputMethodClient$S8
D/dalvikvm( 1196): GC_EXPLICIT freed 1145 objects / 53992 bytes in
80ms
I/ActivityManager(  965): Starting activity: Intent
{ act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] }
I/ActivityManager(  965): Displayed activity
com.google.android.voicesearch/.RecognitionActivity: 539 ms (total 539
ms)
I/AudioService(  965):  AudioFocus  requestAudioFocus() from
android.media.audiomana...@43f1eb48
I/MicrophoneInputStream( 1196): Starting voice recognition with audio
source VOICE_RECOGNITION
W/AudioHardwareInterface(  919): getInputBufferSize bad sampling rate:
16000
D/ALSAModule(  919): open called for devices 00040000 in mode 0...
E/ALSALib (  919): external/alsa-lib/src/pcm/pcm.c:2210:
(snd_pcm_open_noupdate) Unknown PCM AndroidCapture
I/ALSAModule(  919): Initialized ALSA CAPTURE device default
D/AcousticsModule(  919): Acoustics set_params stub called with 0.
W/AudioHardwareInterface(  919): getInputBufferSize bad sampling rate:
16000
E/AudioRecord( 1196): Recording parameters are not supported:
sampleRate 16000, channelCount 1, format 1
E/AudioRecord-JNI( 1196): Error creating AudioRecord instance:
initialization check failed.
E/AudioRecord-Java( 1196): [ android.media.AudioRecord ] Error code
-20 when initializing native AudioRecord object.
W/GoogleRecognitionService( 1196): Audio problem
W/GoogleRecognitionService( 1196): java.lang.IllegalStateException:
not open
W/GoogleRecognitionService( 1196):      at
com.google.android.voicesearch.endpointer.MicrophoneInputStream.<init>(Microphone)
W/GoogleRecognitionService( 1196):      at
com.google.android.voicesearch.GoogleRecognitionService.setupMicrophoneInputStrea)
W/GoogleRecognitionService( 1196):      at
com.google.android.voicesearch.GoogleRecognitionService.setupMicrophone(GoogleRec)
W/GoogleRecognitionService( 1196):      at
com.google.android.voicesearch.GoogleRecognitionService.startRecognitionInternal()
W/GoogleRecognitionService( 1196):      at
com.google.android.voicesearch.GoogleRecognitionService.access
$000(GoogleRecognit)
W/GoogleRecognitionService( 1196):      at
com.google.android.voicesearch.GoogleRecognitionService
$1.handleMessage(GoogleRec)
W/GoogleRecognitionService( 1196):      at
android.os.Handler.dispatchMessage(Handler.java:99)
W/GoogleRecognitionService( 1196):      at
android.os.Looper.loop(Looper.java:123)
W/GoogleRecognitionService( 1196):      at
android.os.HandlerThread.run(HandlerThread.java:60)
W/AudioPolicyManagerBase(  919): getOutput() could not find output for
stream 3, samplingRate 0, format 0, channels c, flags0
E/MediaPlayer( 1196): error (-19, 0)
E/MediaPlayer( 1196): Error (-19,0)
D/dalvikvm( 1040): GC_EXPLICIT freed 1822 objects / 107272 bytes in
89ms
#####################################################

As per my understanding, the sample rate that the Voicesearch
Application is trying to set is not being supported by the
AudioHardwareInterface module:

AudioHardwareInterface(  919): getInputBufferSize bad sampling rate:
16000

Even in the code the function(in AudioHardwareInterface.cpp) is
returning error if the sample rate any other value other than 8000:


##############################
size_t AudioHardwareBase::getInputBufferSize(uint32_t sampleRate, int
format, int channelCount)
{
    if (sampleRate != 8000) {
        LOGW("getInputBufferSize bad sampling rate: %d", sampleRate);
        return 0;
    }
    if (format != AudioSystem::PCM_16_BIT) {
        LOGW("getInputBufferSize bad format: %d", format);
        return 0;
    }
    if (channelCount != 1) {
        LOGW("getInputBufferSize bad channel count: %d",
channelCount);
        return 0;
    }

    return 320;
}

########################################

Not able to understand why this restriction on SampleRate/channelCount
is there in the hardware Interface layer
Are we expected to change this code to suit our hardwares.Can some one
help me in resolving this error.

Thanks in Advance.

Regards,
Satya

-- 

3. twlauncher activity - phone hangs continuously

4. Connecting to Licensing server through Local/Remote Server

5. How to change the color..?

6. Maximum size of APK that can Upload to Android Market

7. "Debug certificate expired" error in eclipse android plugins