Detecting long touch press (ACTION_DOWN only)??

by eminemence » Thu, 02 Sep 2010 01:55:07 GMT


Sponsored Links
 Hi,
I want to figure out how to detect that the user has been doing a long
touch press on the screen?
Most of the solutions that I see assume that the DOWN + UP sequence of
events.
Thanks in advance.

--



Detecting long touch press (ACTION_DOWN only)??

by fr4gus » Thu, 02 Sep 2010 02:22:06 GMT


 If you don't have a requirement about how long should be the time to
trigger a long press, you could use

android.view.GestureDetector;

android.view.GestureDetector.SimpleOnGestureListener;

If you need to detect a long in a specific View object, what I do is
to register a OnTouchListener in my View object, that will redirect
the MotioEvent to the GestureDetector. At this point I'm able to
record what View was touched, and keep it in a variable of my current
Activity. Then in the gesture listener I took this variable and use
it. But if someone else knows a better approach I would like to hear
it :).

Best,

fr4gus




--


Sponsored Links


Other Threads

1. Notepadv3 tutorial...

I was working through the Notepad tutorial...
http://developer.android.com/guide/tutorials/notepad/index.html

...and I seem to either have a misunderstanding of what is supposed to
be happening, or the code is not working.


Below are two snippets of code from the tutorial to illustrate my
questions/concerns:

It looks like this is the "menu" that is brought up when you have no
items selected and you press the Menu key...
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        menu.add(0, INSERT_ID, 0, R.string.menu_insert);
        return true;
    }

...this is the behavior that I expected and saw.

However, when I have one of the notes selected, I would expect this
code snippet to run...
        @Override
        public boolean onContextItemSelected(MenuItem item) {
                switch(item.getItemId()) {
        case DELETE_ID:
                AdapterContextMenuInfo info = (AdapterContextMenuInfo)
item.getMenuInfo();
                mDbHelper.deleteNote(info.id);
                fillData();
                return true;
                }
                return super.onContextItemSelected(item);
        }

...but it doesn't :(

Can anyone help me out here?

I can never get the "delete" option to show up in the tutorial.

Thanks for  your help!
-Matt

-- 

2. /proc/wakelocks kernel Null pointer panic

Hi Arve Hjnnevg,
I met a kernel panic that shows NULL pointer dereference while the PC
is at wakelocks_read_proc function. Do you have any idea about this?
The device was just idle. The UeventObserver process tries to read /
proc/wakelocks
then this panic happens..But this is not easy to reproduce. Below are
the logs:
Thanks a lot.
Johnny

<1>[ 9150.909144] Unable to handle kernel NULL pointer dereference at
virtual address 00000000
<1>[ 9150.909176] pgd = 8d374000
<1>[ 9150.909191] [00000000] *pgd=27000031, *pte=00000000,
*ppte=00000000
<4>[ 9150.909229] Internal error: Oops: 17 [#1] PREEMPT
<4>[ 9150.909246] Modules linked in: AudioTuning oem2(P) PSALS(P)
oem(P) {*filter*}(P) bck(P) [last unloaded: ar6000]
<4>[ 9150.909319] CPU: 0    Tainted: P            (2.6.29 #131)
<4>[ 9150.909369] PC is at wakelocks_read_proc+0x58/0xfc
<4>[ 9150.909391] LR is at 0x7359e885
<4>[ 9150.909413] pc : [<800b35d8>]    lr : [<7359e885>]    psr:
80000093
<4>[ 9150.909424] sp : 890d1e98  ip : 00000000  fp : 890d1ecc
<4>[ 9150.909444] r10: 2e829200  r9 : 20000013  r8 : 00000000
<4>[ 9150.909466] r7 : 8ca61000  r6 : 804cf4c0  r5 : 8ca61793  r4 :
00000000
<4>[ 9150.909489] r3 : 00000000  r2 : 8ca6177a  r1 : fffffffb  r0 :
00000019
<4>[ 9150.909513] Flags: Nzcv  IRQs off  FIQs on  Mode SVC_32  ISA
ARM  Segment user
<4>[ 9150.909538] Control: 00c5387d  Table: 27f74008  DAC: 00000015
<4>[ 9150.909558] Process UEventObserver (pid: 1318, stack limit =
0x890d0260)
<4>[ 9150.909581] Stack: (0x890d1e98 to 0x890d2000)
<4>[ 9150.909596]
1e80:                                                       00000c00
890d1ee8
<4>[ 9150.909656] 1ea0: 00001000 00000000 00000000 00001000 00000c00
8ca61000 00000000 2e829200
<4>[ 9150.909719] 1ec0: 890d1f1c 890d1ed0 8011d060 800b358c 890d1eec
00000000 87939260 890d1f70
<4>[ 9150.909786] 1ee0: 8cc42920 890d0000 00000000 00000000 00001000
8011cf5c 8cc42920 87939260
<4>[ 9150.909849] 1f00: 00001000 890d1f70 890d0000 2e829200 890d1f44
890d1f20 80117868 8011cf68
<4>[ 9150.909916] 1f20: 87939260 2e829200 890d1f70 00001000 2e829200
30ac5da4 890d1f6c 890d1f48
<4>[ 9150.909981] 1f40: 800de3fc 801177ec 800df328 8c930290 00000000
00000000 87939260 00001000
<4>[ 9150.910046] 1f60: 890d1fa4 890d1f70 800de7e0 800de354 00000000
00000000 00000000 00000001
<4>[ 9150.910111] 1f80: 00000005 0010bcc8 000002e0 000000b8 00000003
80033004 00000000 890d1fa8
<4>[ 9150.910174] 1fa0: 80032e80 800de7a8 0010bcc8 000002e0 0000004d
2e829200 00001000 2e829200
<4>[ 9150.910239] 1fc0: 0010bcc8 000002e0 000000b8 00000003 30bc5da0
30ac5db8 30ac5da4 00000001
<4>[ 9150.910303] 1fe0: 6d2375c4 30bc5d50 6d216607 6fe0c2ec 00000010
0000004d 00000000 00000000
<4>[ 9150.910368] Backtrace:
<4>[ 9150.910386] [<800b3580>] (wakelocks_read_proc+0x0/0xfc) from
[<8011d060>] (proc_file_read+0x104/0x278)
<4>[ 9150.910451] [<8011cf5c>] (proc_file_read+0x0/0x278) from
[<80117868>] (proc_reg_read+0x88/0x9c)
<4>[ 9150.910501] [<801177e0>] (proc_reg_read+0x0/0x9c) from
[<800de3fc>] (vfs_read+0xb4/0x144)
<4>[ 9150.910563] [<800de348>] (vfs_read+0x0/0x144) from [<800de7e0>]
(sys_read+0x44/0x70)
<4>[ 9150.910614]  r7:00001000 r6:87939260 r5:00000000 r4:00000000
<4>[ 9150.910654] [<800de79c>] (sys_read+0x0/0x70) from [<80032e80>]
(ret_fast_syscall+0x0/0x2c)
<4>[ 9150.910721]  r8:80033004 r7:00000003 r6:000000b8 r5:000002e0
r4:0010bcc8
<4>[ 9150.910768] Code: ea000002 ebffff5b e5944000 e0855000
(e5943000)
<0>[ 9150.910974] Kernel panic - not syncing: Fatal exception

-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website:  http://www.***.com/ 

3. Paging david yg mu beli matrix di bandung

4. inhibit device

5. Powertop tool issue on OMAP_Zoom

6. beagle board android port

7. setbackgrounddrawable from sd card