Android :: Instrumentation Object To Generate Keypress

Apr 27, 2010

I developed an application to generate keypress. I find out that we can use Instrumentation object to generate. However, when I run the following code, I got these errors.

04-27 16:12:16.720: ERROR/AndroidRuntime(4406):
Caused by: java.lang.RuntimeException: This method can not be called from the main application thread 04-27 16:12:16.720:
ERROR/AndroidRuntime(4406): at 1427)
04-27 16:12:16.720: ERROR/AndroidRuntime(4406): at
04-27 16:12:16.720: ERROR/AndroidRuntime(4406): at 871)

@Override protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub super.onCreate(savedInstanceState);
setContentView(R.layout.main); }
@Override protected void onStart() { // TODO Auto-generated method stub super.onStart();
//press key Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_1); }
@Override protected void onStop() { // TODO Auto-generated method stub super.onStop(); }

Android :: Instrumentation Object to Generate Keypress

Android :: How Can I Get Current Activity Object In Instrumentation Object?

Sep 9, 2009

I want to do some automated testcase with Instrumentation . Suggest that my AUT has 2 Activity. After clicking the button in ther first Activity, the second one will be shown with new content base on what we enter in the first Activity.) Instrumentation provides us the function called startActivitySync() and return the Activity object for processing. My question is how we can get the pointer of the second Activity after the it is shown by clicking the button on the first activity.?

View 2 Replies View Related

Android :: Cast Picture Object To Bitmap Object

Jun 8, 2009

I would like to convert a Picture object to Bitmap object in memory, without writing data to disk.

View 2 Replies View Related

Android : Get Activity Object From Intent Object

Sep 21, 2009

I have an Activity that running on system. I can get the Intent that is used to start the activity. But i don't know how to get the Activity object from the Intent object or something else. Can anyone tell me how to do this??? Note that, I don't use Instrumentation object.

View 11 Replies View Related

Android :: How To Get Any Keypress Event With Example?

Nov 13, 2010

I want to get the key value when user pressed any key and also perform action based on the key pressed in android. e.g. if user pressed 'A' key then I want to get that value, compare, do something.
Uses: Eclipse as IDE

View 1 Replies View Related

Android :: Alarm Not Working At All On HTC Until Keypress

Dec 2, 2009

My girlfriend recently got the HTC Tattoo (running Android 1.6) and she's having major issues with the alarm on the Clock application. Whenever she sets the alarm to wake up in the morning, it doesnt go off at the desired time. There's no sound or not waking of the screen. The alarm does finally sound when the screen is woken, and this can be 20 minutes or so after the alarm *should* have sounded! It works ok if the alarm is set to go off in 5 minutes time or so, but it seems like Android forgets to ring the alarm until the screen is woken and then does it.Can anyone provide any insight into this issue? I have seen that there are other threads where the alarm doesn't work but they dont cover this behavior.

View 11 Replies View Related

Android :: How To Catch Phone Keypress With SDK?

Feb 14, 2010

How can I catch a phone keypress with the android SDK? I've been looking around for hours without finding anything.For example:
In some cases, I want to catch the message when a user presses the "hang up" button on the phone, and then discard the message before it reaches the OS.

View 1 Replies View Related

Android :: Need To Invoke Keypress Event

Jul 29, 2010

I need to invoke a keypress event in android.

View 2 Replies View Related

Android :: Keypress Event - ASCII Codes For A To Z

Nov 18, 2010

When I press the only character button a to z to perform some action in android what is key ASCII code for a to z can anybody tell how to do in android?

View 2 Replies View Related

Android :: Hide Soft Keyboard On Done Keypress?

Aug 5, 2010

I am struggling with the done button on the soft keyboard. I can't get the soft keyboard Done keypress to hide the keyboard. From another button, it works perfectly with imm.hideSoftInputFromWindow(editText.getApplicationWindowToken(), 0);
but the onKeyListener does not function the way I want. When I hit the editText, the soft keyboard shows up and its content is cleared from characters. The main.xml:

<EditText android:id="@+id/answer"
android:layout_gravity="center_horizontal" android:textSize="36px"
android:inputType="phone" android:minWidth="60dp" android:maxWidth="60dp" />

The Java file:
private EditText editText;...
editText = (EditText)findViewById(;
editText.setOnKeyListener(onSoftKeyboardDonePress); ...
// method not working: private View.OnKeyListener onSoftKeyboardDonePress=new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getKeyCode() == KeyEvent.FLAG_EDITOR_ACTION) {
// code to hide the soft keyboard
imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getApplicationWindowToken(), 0); }
return false; } };
private View.OnClickListener onKeyboard=new View.OnClickListener() {
public void onClick(View v) { editText.setText(""); } };

The working method using a button (in the same java file):
private View.OnClickListener onDone=new View.OnClickListener() {
public void onClick(View v) { ....
// code to hide the soft keyboard
imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getApplicationWindowToken(), 0); } };
When I press key no "9" the keyboard hides.

View 2 Replies View Related

Android :: Unable To Turn Off Vibrate On Keypress Using Swype

Jun 15, 2010

New Swype wont let you turn off vibrate on keypress? Just downloaded the newest version, ( and the setting is listed, but you cannot press it, it is "Dimmed". I am an official Beta tester, and got my version from them, through E-mail. I didn't steal the .apk

View 2 Replies View Related

Android :: Emulator Stuck On Equals Phantom Keypress

Jul 27, 2010

For some reason, and only on my Dell Vostro 1000 laptop, the Android emulator keeps thinking I have the = key pressed and continually emits a string of "=====" equal signs. This happens no matter what I'm doing in the emulator. It responds to my manual keypresses as well, interspersing them. It happens no matter which version of the Android system I run (2.1, 2.2, etc.) Strangely, it happens even running the Android emulator via a remote desktop session where the remote desktop client is the laptop and the server is another PC running the emulator. If I run the emulator on the other PC locally (not remote desktop,) the emulator functions fine!

This problem didn't occur when I first installed the SDK and as far as I know no other software has been installed since then. I tried clicking the "clear user data" from the emulator launcher and still no effect. I have also tried deleting the SDK directory and reinstalling it, but the effect is still there.
Update: I found another application that exhibits this behavior. ScummVM when opening a dialog to save the game also receives these phantom keypresses. It persists in Windows 7.

View 4 Replies View Related

Android :: Instrumentation Tag Internals

Jun 9, 2010

Would like to know the best place to get more details on this tag 'instrumentation' for the manifest file.

<instrumentation android:targetPackage='' android:name='android.test.InstrumentationTestRunner' android:label='TestTezzD' android:functionalTest='true' android:handleProfiling='true'/>

Unable to understand its working, specially, how does the InstrumentationTestRunner find all the test cases and what is the way to write the manifest so that it runs only perticular suite and not all the test cases.

View 2 Replies View Related

Android :: Overriding Dialog Preference Default Back Keypress

Jul 7, 2010

By default, when in DialogPreference you press back button, it mimics that you've pressed NegativeButton. I'd like to override that but can't find an easy way except to recreate DialogPreference from scratch (which at the moment seems like an overkill), because I'd like that PositiveButton set something, NegativeButton to unset something, and back key to leave things as they were (i.e. to not unset something). I've even tried to override showDialog() but: a) its not simple, b) I don't think I should mess too much with internals of OS supplied code like a bunch of private "m" variables.

View 1 Replies View Related

Android :: Hiding Keyboard In Override Done Keypress Of Edit Text

Apr 18, 2010

I have used a bit of Android code to override the "Done" button in my EditText field:
myEditField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) { mySubroutine();
return true; } return false; } } );

Activating the field calls up the keyboard, and pressing "Done" evaluates mySubroutine() successfully. However, the keyboard no longer goes away when I press "Done". How do I restore this default behavior to the routine?

View 3 Replies View Related

Android :: Launching Instrumentation From ApiDemos

Mar 1, 2010

Going through the ApiDemos sample code (in Android 2.1 platform), I saw that there are two activities that make use of the Instrumentation class: ContactsFilter and LocalSample. However, I'm having trouble finding the menu that will launch any one of these activities from the ApiDemos application. I just want to be able to run ApiDemos and hit the breakpoint in one of these Activities so I can understand how the Instrumentation class works. proper navigation in ApiDemos to launch ContactsFilter or LocalSample?

View 2 Replies View Related

Android :: Can't Run Some Test Case In Instrumentation

Dec 8, 2009

I have added the "android.test.runner" user library and "android.test.InsturmentationTestRunner" in instrumentation. But when i run the test in Instrumentation, 0 test has been run.

My test class is as below: package;


View 2 Replies View Related

Android :: Using Instrumentation Testing Framework

Oct 17, 2010

How do I use instrumentation testing framework to test flow between activities? The example goog gives is for one activity only.

View 4 Replies View Related

Android :: Instrumentation Framework Query

Jun 3, 2009

I am trying to write a simple test framework. This is what I want to do: My actual test is an apk file on android device, and I write a TestCase or some instrumentation for that which runs on host side. I trigger the test using adb commands or some IDE.I am able to refer to some examples which does above.Now what I want to know is any way of getting results back using any api available in TestCase or such class.This result can be any string value or an object too.

1. can I use TestResult for this purpose ? I expect it ot be similar to function calland return value from function.i.e. on completion of test I should get back the result in a structured way probably defined by me.Is this possible at all.

2. or return value is always going to be put to stdout? or logcat? do I parse and collect stdout or logcat prints into a file?

any input would be of great help.

View 2 Replies View Related

Android :: App Crashes While Testing Through Instrumentation

Sep 27, 2010

I have separated java code from Android code and have two projects. Android dependent on Java project. Now i want to get the memory trace of the Java project on Android. For that I have created Androd Junit Project implementing Android Instrumentation, and a dummy android project dependent on my actual java project.(as I only want to get memory trace of java project on android).Problem is when I execute Android Junit project, and give a reference of dummy project removing java project dependency, all tests(dummy) run fine.But when I run junit project, with dummy android proj keeping dependency on java project, my application crashes.I get an error message like : "Process crash" not getting any error message in logcat. No clue whats wrong with code.Any help is highly needed.

View 1 Replies View Related

Android :: How To Run Instrumentation Tests On Device?

Sep 16, 2009

Can you please tell me the process for running the tests on device? currently I am using the eclipse IDE to run the tests as Android Junit tests. And I would like to run the unit tests on device.

View 2 Replies View Related

Android :: Instrumentation Testing Called Robotium

Feb 22, 2010

I found a tool for Instrumentation Testing called Robotium.It is easy and simple for black box testing of android applications.
We can use it as follows:


How can we use it for webviews and listviews etc.

View 4 Replies View Related

Android :: Abort Instrumentation Test Case

Feb 11, 2009

I have an instrumentation test case that is waiting for an incoming call. I would like to abort this test case after some time from outside of this test case. Is there any argument to "adb shell am instrument" command that will stop the on going instrument test case?

View 2 Replies View Related

Android :: Instrumentation Test Cases In Groovy

Mar 3, 2010

Can we write instrumentation test cases for an android application in Groovy? If so , how ?

View 1 Replies View Related

Android :: Motion Events In Instrumentation Testing

Feb 27, 2010

This is the code for motion events in my instrumentation testing.

long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();

MotionEvent event = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_DOWN, 100,100, 0);

MotionEvent event2 = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_UP, 100, 100, 0);...............................

View 1 Replies View Related

Android :: Way To Test A Service Using Instrumentation Framework?

Aug 4, 2010

Do anyone have idea about testing a service using instrumentation framework.

View 6 Replies View Related

General :: Does Using Vibrate On Keypress Use Battery

Feb 26, 2013

I am wondering if using vibrate on keypress uses battery?

View 3 Replies View Related

General :: Will Vibrate On Keypress Use Battery?

Nov 28, 2012

will enabling vibrate on key press (when you hit a letter or anything it vibrates) drain or use any battery?

View 8 Replies View Related

Android :: Run Instrumentation Tests From Command Line (in Kubuntu)?

Mar 22, 2010

We are able to run instrumentation tests of Android from the command line on Windows by launching: adb shell am instrument -w <package.test>/android.test.InstrumentationTestRunner. This gives us good results. Using the same architecture, we are unable to run the same in Kubuntu. We have the same setup in Kubuntu. Can someone let us know, if there are packages with same name.. Then what package will the adb shell point? How will the emulator connect with adb shell from cmd line? DO we need to do any changes to do so in Kubuntu?

View 1 Replies View Related

Android :: Pass Property Value Argument To An Instrumentation Test Runner

Mar 3, 2010

I use the following instrumentation testrunner command line to run JUnit tests on my project :


and it runs OK.

I am now trying to pass a property value argument to my instrumentation test runner, something equivalent to the eclipse vm argument -Dcom.myApplication.myProperty="String" The value ("String") of a property (com.myApplication.myProperty) must be defined in the command line. I tried to bend my command line to make this work, changing it for example into :


but didn't manage to make it work correctly. Is there a way to make this work ?

View 4 Replies View Related

Copyrights 2005-15, All rights reserved