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. Should we use jade androide to develop application?

Hi All,

I am building a social networking application for ADC-II. This needs
peer-to-peer communications.Since GTalk service is not there any more
(hoping some variant will be back in future), I have one easy option
to use JADE.

But JADE requires a running JADE platform to function properly. And
definitely this is a drawback if I use JADE.

Dan, your comments will be highly appreciated.

Thanks,
Sujit

--~--~---------~--~----~------------~-------~--~----~

2. Timeout executing service - how to avoid this?

Hi,

When I debug my application, it suddenly disconnects from the DalvikVM
without throwing an exception. Regarding this, the emulator shows an
ANR dialog. It happens some time after I have started a service to do
an operation, by a Broadcast receiver. The operation does take pretty
long time, because it is parsing a xml document. It does not stop
after a special point in my code. I know that a Broadcast receiver
needs to be executed fast, but when I start a service by the
context.startService(Intent) method it shouldn't wait for the
service's execution, should it?

I've attached the log (which do have a line with
"07-18 20:35:24.148: WARN/ActivityManager(583): Timeout executing
service: ServiceRecord{43818238
com.kaloersoftware.flickrwall/.FlickrWallService}"

Can it help if I do the xml parsing in a thread?


07-18 20:35:24.148: WARN/ActivityManager(583): Timeout executing
service: ServiceRecord{43818238
com.kaloersoftware.flickrwall/.FlickrWallService}
07-18 20:35:31.357: INFO/ActivityManager(583): ANR (application not
responding) in process: com.kaloersoftware.flickrwall
07-18 20:35:31.357: INFO/ActivityManager(583): Annotation: Executing
service ComponentInfo{com.kaloersoftware.flickrwall/
com.kaloersoftware.flickrwall.FlickrWallService}
07-18 20:35:31.357: INFO/ActivityManager(583): CPU usage:
07-18 20:35:31.357: INFO/ActivityManager(583): Load: 2.59 / 0.99 /
0.87
07-18 20:35:31.357: INFO/ActivityManager(583): CPU usage from 11984ms
to 214ms ago:
07-18 20:35:31.357: INFO/ActivityManager(583):   system_server: 117% =
82% user + 34% kernel
07-18 20:35:31.357: INFO/ActivityManager(583):
com.kaloersoftware.flickrwall: 39% = 39% user + 0% kernel
07-18 20:35:31.357: INFO/ActivityManager(583):   qemud: 7% = 0% user +
7% kernel
07-18 20:35:31.357: INFO/ActivityManager(583):   events/0: 2% = 0%
user + 2% kernel
07-18 20:35:31.357: INFO/ActivityManager(583): TOTAL: 100% = 82% user
+ 17% kernel
07-18 20:35:31.387: INFO/ActivityManager(583): Removing old ANR trace
file from /data/anr/traces.txt
07-18 20:35:31.407: INFO/Process(583): Sending signal. PID: 1786 SIG:
3
07-18 20:35:31.417: INFO/Process(583): Sending signal. PID: 1743 SIG:
3
07-18 20:35:31.447: INFO/Process(583): Sending signal. PID: 760 SIG: 3
07-18 20:35:31.447: INFO/dalvikvm(760): threadid=7: reacting to signal
3
07-18 20:35:31.507: INFO/Process(583): Sending signal. PID: 695 SIG: 3
07-18 20:35:31.507: INFO/dalvikvm(695): threadid=7: reacting to signal
3
07-18 20:35:31.527: INFO/Process(583): Sending signal. PID: 647 SIG: 3
07-18 20:35:31.527: INFO/dalvikvm(647): threadid=7: reacting to signal
3
07-18 20:35:31.537: INFO/Process(583): Sending signal. PID: 679 SIG: 3
07-18 20:35:31.537: INFO/dalvikvm(679): threadid=7: reacting to signal
3
07-18 20:35:31.547: INFO/Process(583): Sending signal. PID: 732 SIG: 3
07-18 20:35:31.547: INFO/dalvikvm(732): threadid=7: reacting to signal
3
07-18 20:35:31.547: INFO/Process(583): Sending signal. PID: 725 SIG: 3
07-18 20:35:31.547: INFO/dalvikvm(725): threadid=7: reacting to signal
3
07-18 20:35:31.567: INFO/Process(583): Sending signal. PID: 583 SIG: 3
07-18 20:35:31.567: INFO/dalvikvm(583): threadid=7: reacting to signal
3
07-18 20:35:31.567: INFO/dalvikvm(760): Wrote stack trace to '/data/
anr/traces.txt'
07-18 20:35:31.667: INFO/dalvikvm(695): Wrote stack trace to '/data/
anr/traces.txt'
07-18 20:35:31.727: DEBUG/Zygote(553): Process 1786 terminated by
signal (3)
07-18 20:35:31.757: DEBUG/Zygote(553): Process 1743 terminated by
signal (3)
07-18 20:35:31.787: INFO/dalvikvm(725): Wrote stack trace to '/data/
anr/traces.txt'
07-18 20:35:31.797: INFO/dalvikvm(647): Wrote stack trace to '/data/
anr/traces.txt'
07-18 20:35:31.817: INFO/dalvikvm(679): Wrote stack trace to '/data/
anr/traces.txt'
07-18 20:35:31.827: INFO/dalvikvm(732): Wrote stack trace to '/data/
anr/traces.txt'
07-18 20:35:31.827: INFO/dalvikvm(583): Wrote stack trace to '/data/
anr/traces.txt'
07-18 20:35:31.847: DEBUG/dalvikvm(583): GREF has decreased to 199
07-18 20:35:31.857: INFO/WindowManager(583): WIN DEATH: Window
{43746898 com.android.launcher/com.android.launcher.Launcher
paused=false}
07-18 20:35:31.918: INFO/Process(583): Sending signal. PID: 662 SIG: 3
07-18 20:35:31.927: INFO/dalvikvm(662): threadid=7: reacting to signal
3
07-18 20:35:31.937: INFO/dalvikvm(662): Wrote stack trace to '/data/
anr/traces.txt'
07-18 20:35:31.937: INFO/Process(583): Sending signal. PID: 622 SIG: 3
07-18 20:35:31.947: INFO/dalvikvm(622): threadid=7: reacting to signal
3
07-18 20:35:31.957: INFO/ActivityManager(583): Process
com.kaloersoftware.flickrwall (pid 1786) has died.
07-18 20:35:31.957: WARN/ActivityManager(583): Scheduling restart of
crashed service com.kaloersoftware.flickrwall/.FlickrWallService in
5000ms
07-18 20:35:31.967: INFO/dalvikvm(622): Wrote stack trace to '/data/
anr/traces.txt'
07-18 20:35:31.977: INFO/ActivityManager(583): Process
android.process.acore (pid 1743) has died.
07-18 20:35:32.107: INFO/ActivityManager(583): Start proc
android.process.acore for activity com.android.launcher/.Launcher:
pid=1793 uid=10003 gids={3003}
07-18 20:35:32.327: ERROR/ActivityThread(583): Failed to find provider
info for android.server.checkin
07-18 20:35:32.327: WARN/Checkin(583): Can't log event
SYSTEM_SERVICE_LOOPING: java.lang.IllegalArgumentException: Unknown
URL content://android.server.checkin/events
07-18 20:35:32.458: INFO/jdwp(1793): received file descriptor 20 from
ADB
07-18 20:35:33.317: INFO/ActivityThread(1793): Publishing provider
user_dictionary:
com.android.providers.userdictionary.UserDictionaryProvider
07-18 20:35:33.428: INFO/ActivityThread(1793): Publishing provider
com.android.googlesearch.SuggestionProvider:
com.android.googlesearch.SuggestionProvider
07-18 20:35:33.527: INFO/ActivityThread(1793): Publishing provider
contacts;call_log: com.android.providers.contacts.ContactsProvider
07-18 20:35:33.667: WARN/ActivityManager(583): Unable to start service
Intent { action=android.accounts.IAccountsService comp=
{com.google.android.googleapps/
com.google.android.googleapps.GoogleLoginService} }: not found
07-18 20:35:33.677: WARN/AccountMonitor(1793): Couldn't connect to
Intent { action=android.accounts.IAccountsService comp=
{com.google.android.googleapps/
com.google.android.googleapps.GoogleLoginService} } (Missing service?)
07-18 20:35:33.687: INFO/ActivityThread(1793): Publishing provider
com.android.launcher.settings: com.android.launcher.LauncherProvider
07-18 20:35:34.367: DEBUG/dalvikvm(1793): GC freed 2657 objects /
178088 bytes in 145ms
07-18 20:35:34.897: DEBUG/HomeLoaders(1793): load applications
07-18 20:35:34.907: DEBUG/HomeLoaders(1793): loading user items
07-18 20:35:34.917: DEBUG/HomeLoaders(1793):   --> starting workspace
loader
07-18 20:35:35.147: INFO/ActivityManager(583): Displayed activity
com.android.launcher/.Launcher: 3134 ms
07-18 20:35:35.947: DEBUG/HomeLoaders(1793):   --> starting
applications loader
07-18 20:35:37.017: INFO/ActivityManager(583): Start proc
com.kaloersoftware.flickrwall for service
com.kaloersoftware.flickrwall/.FlickrWallService: pid=1804 uid=10031
gids={3003}
07-18 20:35:37.188: INFO/jdwp(1804): received file descriptor 10 from
ADB


Thank you very much,
Kaloer
--~--~---------~--~----~------------~-------~--~----~

3. Low accuracy of the accelerometer Sensor

4. Change RamDisk size

5. GPS on G1/G2

6. Best practise to deal with killed services?

7. Best practise to deal with killed services?