I'm trying to use a gesture overlay on a activity that is used as a splash screen.
The problem is when I : gOverlay = (GestureOverlayView) this.findViewById(R.id.gOverlay);
, gOverlay is null.
This is my XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center" android:background="#000000"
android:weightSum="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.11">
<android.gesture.GestureOverlayView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/gOverlay"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:visibility="visible"
android:background="#000000"
>
</android.gesture.GestureOverlayView>
</RelativeLayout>
</LinearLayout>
This is Splash java code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
/** set time to splash out */
Bundle extras = getIntent().getExtras();
if (extras != null) {
Duration = extras.getString("Duration");
}
welcomeScreenDisplay = 4000;
try {
welcomeScreenDisplay = Integer.parseInt(Duration);
} catch (Exception x) {
}
gLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
if (!gLibrary.load()) {
finish();
}
gOverlay = (GestureOverlayView) this.findViewById(R.id.gOverlay);
gOverlay.setGestureVisible(false);
gOverlay.addOnGesturePerformedListener(this);
/** create a thread to show splash up to splash time */
Thread welcomeThread = new Thread() {
int wait = 0;
@Override
public void run() {
try {
super.run();
while (wait < welcomeScreenDisplay) {
sleep(100);
wait += 100;
}
} catch (Exception e) {
System.out.println("EXc=" + e);
} finally {
finish();
}
}
};
welcomeThread.start();
}
What i'm trying to do is : 1. When user presses back button Splash screen will show. 2. This splash screen will be on the screen for n seconds 3. If the user draw a 'L' on the splash screen, implicit on Gesture Overlay, main activity will .finish()
Thanks