I'm developing an app which is designed to capture writing on the canvas. The app is designed for use with HTC Flyer (Android 2.3.3).
This device already has Scribbler installed, so I have disabled "Auto launch Scribbler mode" but left "Pen history for each app" checked.
In my tests, I have found the app can detect my fingers on the touchscreen but not the stylus. I pressed a combination of buttons on stylus to no avail.
I have based the code on TouchPaint from Android Developers: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.html
I did not import the package as described in the above code
com.example.android.apis.graphics;
In my Eclipse IDE, it reported the following as a problem suggesting I should remove the Override attribute.
@Override
public boolean onHoverEvent(MotionEvent event) {
return onTouchOrHoverEvent(event, false /*isTouch*/);
}
So I did.
I have added the following to the manifest.
<uses-configuration android:reqTouchScreen="stylus"/>
<uses-configuration android:reqTouchScreen="finger"/>
The app can detect my finger movements on the touchscreen but never my stylus. Why?
I also noted that in Android Developers guide the MotionEvents refers to getToolType but I cannot see it in my "Intellisense" in Eclipse.
http://developer.android.com/reference/android/view/MotionEvent.html#getToolType%28int%29
The method getToolType is not available in my Android code. I thought I could use this method to check the type of the touch input e.g a finger or a stylus.
I also added a onTouchListener for the PaintView (based on TouchPaint code).
this.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return touchSurface(v, event);
}
});
touchSurface code
private boolean touchSurface(View v, MotionEvent event) {
boolean complete = true;
int pAction = event.getAction();
int pActionIndex = event.getActionIndex();
Log.i("SignName", "touchSurface event fired.");
Log.i("SignName", "Pointer Action: " + pAction + ", pActionIndex: " + pActionIndex);
return complete;
}
When I use my finger, the above event is fired. When I use a stylus, it's not fired. Why?
I wonder if this problem is isolated to the HTC Flyer, it's because it has a Scribbler app which overrides my app settings or my code is wrong.
Can you please help me?
(Update: 27th April 2012) I found what the problem was. It was the dedicated stylus HTC Flyer that caused the confusion.
I thought if this stylus didn't work, then any other stylus won't work too. However, I did try a different stylus and it worked.
Thanks for your help, though.