Android :: Test A Call To SetContentView?
May 25, 2010How do I write a unit test to determine that the layout used in setContentView(int layoutId) has been called and corresponds to the proper layout for a given activity?
View 1 RepliesHow do I write a unit test to determine that the layout used in setContentView(int layoutId) has been called and corresponds to the proper layout for a given activity?
View 1 RepliesCan you please tell me if you know how to get the Andorid unit test instrementation to call my activity's onActivityResult()?
I can't find anything here: http://code.google.com/android/reference/android/app/Instrumentation.
I am creating a layout through code and want to add a View to that layout. The view which is to be added is defined in the xml file. Is there any way to use an View from xml before calling setContentView method. Because we can not call findViewById before setContentView.
View 2 Replies View RelatedWe originally bought 5 for our business. Of those 5, 2 have been returned and exchanged for Blackberries. We continue to have terrible Signal Strength, and in 2 phones a very loud echo. All other little bugs aside, im looking for some answers. Since I didnt see any side by side tests, I thought I would
1. I tested the signal strength at 5 locations. All locations had great 3g speeds for all the phones. The first INC is an original phone, and the second INC is a replacement.
Droid Eris INC1 INC2
-75 -80 -98 -96
-85 -74 -101 -100...
My question is, how can i have GREAT 3g speeds with all the phones, yet have a terrible signal strength. I'm on my 2nd phone and still have the same issues. ( So its not a bad batch)
2. The first thing the other 2 users of the phones mentioned right out of the box there was a very defined echo. The echo was of their own voice, not the other person on the line. I've noticed it on and off, but nothing to bad. People also complain they can hear the echo, making us hard to hear on the phone. I really like the Incredible, but I guess unless someone from Verizon tells me to wait for an update, or someone here has a solution Im gonna have to go back to the Blackberry. Anyone else having the same problems?....
Was flipping through the xda forum the other day and found a hidden menu you can enter through the lock screen;
When the screen is on but locked you press menu(left hardware key), back(right hardware key), back, menu, back, menu, menu, back
This enters you into service menu. decided to check out the service test menu and there's a test option for 'earphone'. when you press it... my my how clear the earpiece can sound - with this kind of loudness and clarity i might have a chance of hearing my phone calls outside of an isolated soundproof room!
I have use setContentView(R.layout.main) in the onCreate as using XML to set my whole layout.
But now I need add some button dynamicly in the code so I think I need get the layout of the Activity again.
So need I get the laytout of the activity again? If I am right, how to get it?
I want to custmize an alert dialog. I can set the content using setContentView and other api's, but Android always gives a white border with rounded edges around the Alert dialog. Is it possible to remove this white border from the dialog box?
View 4 Replies View RelatedI have been trying to set a new xml layout, when a particular item on this list is clicked.
Am I missing something, because the emulator crashes when clicked?! setContentViewById(R.id.newxml file)
public class intentProject extends ListActivity
{
ListView list;
ArrayAdapter<String> aa;
List<String> data = new ArrayList<String>();
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);........................
My code is calling setContentView(R.layout.someLayoutID); from an activities' onCreate method. The activity is launched with the following: Code...
View 4 Replies View RelatedI see a strange problem when I try to set a TextView, instead of a layout file via setContentView.
Case 1: i.e. if I do the following, it works fine...
TextView tv = new TextView(this); tv.setText("Hello World"); setContentView(tv);
Everything is OK.
Case 2: But suppose I have a main.xml file with a TextView in it and I try the following:
=========== View tv = findViewById(R.id.textview); setContentView(tv); =========== I get a Force Close with the below error
09-27 00:08:26.620: ERROR/AndroidRuntime(1595): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f050001 type #0x12 is not valid 09-27 00:08:26.620: ERROR/AndroidRuntime(1595): at android.content.res.Resources.loadXmlResourceParser(Resources.java: 1801) 09-27 00:08:26.620: ERROR/AndroidRuntime(1595): at android.content.res.Resources.getLayout(Resources.java:685) 09-27 00:08:26.620: ERROR/AndroidRuntime(1595): at android.view.LayoutInflater.inflate(LayoutInflater.java:318) 09-27 00:08:26.620: ERROR/AndroidRuntime(1595): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 09-27 00:08:26.620: ERROR/AndroidRuntime(1595): at com.android.myhelloworld.SimpleActivity.onCreate(SimpleActivity.java: 22)
Case 3: I even tried to inflate the xml and set the view but even that resulted in a force close.
Am I missing something here ?
I'm writing an Android JUnit test and want to copy/reset a test fixture file (it's an SQLite database file.) If I were within the main application, I know I could just place the file in the assets directory and use getResources().getAssets().open(sourceFile).However, this API appears to be unavailable from the ActivityInstrumentationTestCase2 class.Is there an easy way to copy a file over from the testing PC, or should I just keep a fresh copy of a test fixture on the device and copy it over a temporary file?
View 2 Replies View RelatedI am using ActivityInstrumentationTestCase2 to do some test for an activity. I get a button in the setUp() method like this: protected void setUp() throws Exception {super.setUp(); act = getActivity(); btn = Button)act.find ViewById ( R.id.bike_button ); // this button has been defined in layout} Then I use this button to perform a click in a test method like this: public void testBikeButton(){ //click the bike button btn.performClick();}
View 7 Replies View RelatedI am using below code where , i want to show dialog in front and loading content in background but not able to do the same .code...
View 3 Replies View RelatedWhen I put the setContentView in thread as below, it crashes while running in emulator. code...
View 2 Replies View RelatedI have never used JUnit before, and now I'm trying to set it up on an Android project.My project under test is fairly complex, including some JNI, but my test project, at the moment, is completely trivial. I have found many examples (that look totally different) online of how to make a test project, but it seems that no matter which one I follow, I get the same results.Here's my JUnit project code:package com.mycompany.myproject.test;
import android.test.AndroidTestCase;public class SimpleTestCaseExample extends Android TestCase {public void test_testOne() {fail("Just Always Fail");When I run, I see the following in Logcat:
stdout INSTRUMENTATION_STATUS: numtests=2
stdout INSTRUMENTATION_STATUS: test=test_testOne
stdout INSTRUMENTATION_STATUS_CODE: 0
stdout INSTRUMENTATION_STATUS: id=InstrumentationTestRunner
stdout INSTRUMENTATION_STATUS: current=2
stdout INSTRUMENTATION_STATUS: class=com.mycompany.myproject.test.SimpleTestCaseExample
stdout INSTRUMENTATION_STATUS: stream=
stdout INSTRUMENTATION_STATUS: numtests=2
stdout INSTRUMENTATION_STATUS: test=testAndroidTestCaseSetupProperly
stdout INSTRUMENTATION_STATUS_CODE: 1
stdout INSTRUMENTATION_STATUS: id=InstrumentationTestRunner
stdout INSTRUMENTATION_STATUS: current=2
stdout INSTRUMENTATION_STATUS: class=com.mycompany.myproject.test.SimpleTestCaseExample
stdout INSTRUMENTATION_STATUS: stream=.
stdout INSTRUMENTATION_STATUS: numtests=2
stdout INSTRUMENTATION_STATUS: test=testAndroidTestCaseSetupProperly
stdout INSTRUMENTATION_STATUS_CODE: 0
stdout INSTRUMENTATION_RESULT: stream=
stdout Test results for InstrumentationTestRunner=..
stdout Time: 0.07
stdout OK (2 tests)
stdout INSTRUMENTATION_CODE: -1
But, I get the following in the Console:Launching instrumentation android.test. Instrumentation TestRunner on device emulator-5554 Collecting test information Test run failed: No test results I have tried a variety of different things, messing with the basic TestCase class, or the TestSuite class, or a variety of other options. I tried to just go for the most trivial example because I'm really still trying to learn how this works.Whatever I try, I see this error.
I'm working on a school project and I'm researching testing possibilities for Android applications. On this page: http: // developer . android . com/ resources / tutorials /testing /hello android. Google writes about a unit test. Is this really a unit test? A Unit test will not integrate all classes and will not test in his context. So my opinion is it is not a Unit Test but an Integration Test.
View 7 Replies View RelatedSo I have my main activity. It starts out adding a custom SurfaceView called DrawView as the content view with
DrawView drawview = new DrawView(parameters);
this.setContentView(drawview);
now my layout.main.xml is a layout with a video view which I am using to play my cutscenes. I am able to switch to this view by calling a method I made which switches the content view by
this.setContentView(R.layout.main);
which works fine when I am calling this method within the Activity. Only problem is I need to call this method from within DrawView! The method I made to switch to my cutscene is public and I do pass the Activity (named Draw) as a parameter of DrawView.
So when I do call this method from within DrawView my game freezes and will subsequently crash! however it works when method is called locally?
One more video about the fancy touchscreen of the Droid X. This one has happier results! Check it out at the link below.Droid X Touchscreen Test See you later. you'll know why this post is short when you read the blog. running downstairs!
View 5 Replies View RelatedI have a project (that compiles and runs in the emulator.) I have a test project that tests part of this project. This test project also compiles with no problems, but when I try to run (test) it in the emulator, I get a NoClassDefFoundError exception on one of the classes my test class tests (I hope that made sense!) when it starts to run in the emulator. This is coming out of the adb log. I looked in the bin directory (of the test project) for the missing class, but could not find it... Should it be there? I found no reference (apk, etc) of the project I am trying to test either in the test projects bin directory. How does the test project get the classes it needs to test against (in the classpath, I assume.) How do the tested classes get moved to the emulator? I did try running the app before testing, so I know it is installed and runs correctly. BTW, I am using netbeans with the nbandroid plugin.
View 1 Replies View RelatedI am unable to integrate Junit with Android. I am using Junit 3, I have also tried Junit4.
package* com.android.test;
import* com.android.MyActivity;
import* android.app.Activity; *
import* android.test.ActivityInstrumentationTestCase2;
public* *class* TestMyView *extends *
ActivityInstrumentationTestCase2<MyActivity> {
Activity myActivity ;
*public* TestMyView(String pkg, Class<MyActivity> activityClass) {
*super*(pkg, activityClass);
myActivity = getActivity() ;
why CheckBox is always null.
<CheckBox id="@+id/checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" />
code file-
package com.reblogr.reblogrclient;
public class Test extends Activity { /** Called when the activity is first created. */
public CheckBox checkbox;
@Override public void onCreate(Bundle savedInstanceState) { ....................
I use Google Voice (love it) primarily because of it's visual voicemail on my Droid. I do have a Google Voice number, and I'm trying to decide whether to set the Droid app to "make calls using Google Voice" or not.
I have no problem with giving out a different number, and my placed calls seeing the GV number in caller ID.
My question is, does this affect how the call is actually connected, from a quality standpoint? I tired a call both ways, and the sound quality seemed a little bit different. But then, I am an obsessive compulsive weirdo.
Is there any difference in call quality or routing between making a native Verizon call and a Google Voice call on Droid? (Like, does Google voice actual use 3G to connect to Google server over the internetz, then place the phone call?)
I need a GPS application on android so I can test my gps function. Can any one who knows and being so kind to tell me about?
View 5 Replies View RelatedNeed to test apk file on actual G1 device urgently.
Could any anyone with the device please help me on this?
I can use this code make outgoing call.
Intent dial = new Intent(Intent.ACTION_CALL); dial.setData(Uri.parse("tel:5556") );
context.startActivity(dial);
But how to detect call pick up the call or refuses to answer?
I tried PhoneStateListener but not working.
I am trying to make a VoIP application and I wanted to know if it is possible to do the following with the Call Logs content provider -
I want to add new Call Log records for the VoIP call along with the call logs for the regular call. How can I add new records to the existing Call logs content provider?
I want to add custom fields to the Call Logs like a session ID and SIP address(name@domain) field. How can I customize the call logs database?
For the OEM, on the product line,we need to test the earpieces whether it works well. so I want to write a application which will play sounds through the earpieces. i want to know how can i play a sound through the earpieces? or if there is a better way to test the earpieces?
View 3 Replies View RelatedI would like to test my code which check the availability of the Text To Speech lib on the device before using it. For this I need to remove the TTS service which is already installed on my device (HTC Legend). Do you know how to do this ? (I only found to stop the service not to remove it) ...
View 3 Replies View RelatedIs there anything to test the UI of an Android app like Jemmy for Swing?
View 3 Replies View RelatedI am trying to implement serialization for an email application on the android (stroring username, password, server etc.), but in order to test it I have to close the application in the emulator and then re-open it to ensure that it looks and finds the file with the serialized objects. The problem is that when I close the application on the emulator uninstalls the application. I close the application with the finish() function. Any inklings as to why this happens? And it wasn't doing it until further along in my development stage.
View 1 Replies View Related