Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7871473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:55:04+00:00 2026-06-03T01:55:04+00:00

I have written the following code designed for API version 2.3.3 minimum and works

  • 0

I have written the following code designed for API version 2.3.3 minimum and works fine on an emulator designed for that. I have just tried testing the same code on API 4.0 and the onFling gestures I’ve implemented to control the app don’t work. They don’t even seem to be called.

Here is the code.

package com.mystraldesign.memorable;

import java.io.IOException;
import android.app.Activity;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.ClipboardManager;
import android.view.GestureDetector;
import android.view.GestureDetector.OnDoubleTapListener;
import android.view.MotionEvent;
import android.view.Window;
import android.widget.TextView;
import android.widget.Toast;
import com.mystraldesign.memorable.PassGen;

public class MemorableActivity extends Activity implements android.view.GestureDetector.OnGestureListener,OnDoubleTapListener  
{
    //Define text views
    private TextView textView1;
    private TextView textView2;
    private TextView textView3;
    private TextView textView4;

    //Previous password holder
    private String prevPass;

    //Gesture Detectors
    private GestureDetector gTap; 

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);

        gTap  = new GestureDetector(this,(android.view.GestureDetector.OnGestureListener) this);

        //Remove title bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);




        //Define textView
        textView1 = (TextView) findViewById(R.id.textView1);
        textView2 = (TextView) findViewById(R.id.textView2);
        textView3 = (TextView) findViewById(R.id.textView3);
        textView4 = (TextView) findViewById(R.id.textView4);

        //Load font file
        Typeface type = Typeface.createFromAsset(getAssets(),"fonts/optima.ttf"); 

        //Set various textViews to font
        textView1.setTypeface(type);
        textView2.setTypeface(type);
        textView3.setTypeface(type);
        textView4.setTypeface(type);

        prevPass = "Memorable";

    }



    //Password call
    public void newPass()
    {
        //Store Return
        String retn = "";
        PassGen passWord = new PassGen();


        //Generate password
        try 
        {
            retn = passWord.passwordGen(this);
        } 
        catch (IOException e) 
        {

            //Message about Error
            Context context = getApplicationContext();
            CharSequence text = "Ooops Something Went Wrong!";
            int duration = Toast.LENGTH_SHORT;

            //Display message
            Toast toast = Toast.makeText(context, text, duration);
            toast.show();

            textView1.setText("Memorable");


            e.printStackTrace();
        }

        //Update prevPass
        prevPass = textView1.getText().toString();

        textView1.setText(retn);
    }









    /*--------------------------------------*/
    /*Additional gesture code below. */
    /* */
    /*J. Krawczyk 3/5/12*/
    /*--------------------------------------*/



    public boolean onTouchEvent(MotionEvent me){ 
        this.gTap.onTouchEvent(me);
       return super.onTouchEvent(me); 
      }



    public boolean onDown(MotionEvent e) {

      return false;
    }

    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
          float velocityY) 
  {

    String test = textView4.getText().toString();
    if ((velocityX == 0) && (velocityY > 0))
    {

        //Call new password generation or generate random if set
        if(test.equals("Memorable"))
        {
            newPass();
        }
        else if(test.equals("Random"))
        {
            //create new password method
            PassGen pass = new PassGen();

            //Set password
            textView1.setText(pass.randomPassword());
        }
    }
    else if((velocityX == 0) && (velocityY < 0))
    {
        textView1.setText(prevPass);
    }
    else if((velocityY == 0) && (velocityX > 0))
    {

        if(test.equals("Memorable"))
        {
            textView4.setText("Random");
        }
        else if(test.equals("Random"))
        {
            textView4.setText("Memorable");
        }   
    }


    return false;
  }


    public void onLongPress(MotionEvent e) 
    {

    }


    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
      float distanceY) {

     return false;
    }


    public void onShowPress(MotionEvent e) {

    }

    public boolean onSingleTapUp(MotionEvent e) {

     return false;
    }


    //Method to copy password - Depreciated
    public boolean onDoubleTap(MotionEvent e) {

     return false;
    }

    //Method to copy password
    public boolean onDoubleTapEvent(MotionEvent e) {

        //clipboard shite
        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 
        clipboard.setText(textView1.getText());

        //Message about coping
        Context context = getApplicationContext();
        CharSequence text = "Password has been copied to clipboard.";
        int duration = Toast.LENGTH_SHORT;

        //Display message
        Toast toast = Toast.makeText(context, text, duration);
        toast.show();

      return false;
    }



    public boolean onSingleTapConfirmed(MotionEvent e) {

     return false;
    }





}

The console keeps saying it fails to install but it appears on emulator and runs. The same happens when testing on an actual 4.0 device.

2012-05-03 05:57:06 - Emulator] 2012-05-03 05:57:06.471 emulator-arm[5445:1107] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
[2012-05-03 05:57:06 - Emulator] emulator: emulator window was out of view and was recentered
[2012-05-03 05:57:06 - Emulator] 
[2012-05-03 05:57:06 - Memorable] New emulator found: emulator-5554
[2012-05-03 05:57:06 - Memorable] Waiting for HOME ('android.process.acore') to be launched...
[2012-05-03 05:59:24 - Memorable] HOME is up on device 'emulator-5554'
[2012-05-03 05:59:24 - Memorable] Uploading Memorable.apk onto device 'emulator-5554'
[2012-05-03 05:59:26 - Memorable] Installing Memorable.apk...
[2012-05-03 06:01:34 - Memorable] Failed to install Memorable.apk on device 'emulator-5554!
[2012-05-03 06:01:34 - Memorable] (null)
[2012-05-03 06:01:34 - Memorable] Failed to install Memorable.apk on device 'emulator-5554': EOF
[2012-05-03 06:01:34 - Memorable] com.android.ddmlib.InstallException: EOF
[2012-05-03 06:01:34 - Memorable] Launch canceled!

EDITED:

It now runs and installs on all AVD’s (2.3.3 – 4.0) but the gestures still only work on 2.3.3

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:55:05+00:00Added an answer on June 3, 2026 at 1:55 am

    It appears to error of gesture not being recognised was due to me using velocity to determine movement but it is finer controlled on Android 4.0 so was never hitting the velocityX = 0 condition.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a following code to get just the file name without extension
I have the following code that was written without Tests but is actually quite
I have written following code to attach gesture recogniser to multiple imageviews. [imageview1 setUserInteractionEnabled:YES];
I am trying my hands on WPF MVVM. I have written following code in
I have written the following code in SWI-Prolog: :- dynamic state_a/1 . :- dynamic
I have written the following code choice /m Do you want to add another
I have written the following code. But it is removing only &nbsp; not <br>
i have written the following code: As you can see there is a for
I have written the following code in Perl. I want to iterate through a
I have written the following IronPython code: import clr clr.AddReference(System.Drawing) from System import *

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.