Android :: Attempt To Stub Android Activity Class Using PowerMockito Throws RuntimeException - Stub

Sep 17, 2010

I found this example where they used PowerMock and EasyMock to stub/mock the Menu and MenuItem classes for android. I have been trying to do something similar with PowerMock and Mockito with the Activity class.

I understand that a lot of the methods are final and that in the Android.jar they all just throw RuntimeException("Stub!").

I also understand that this test isn't complete but I just wanting to see if it is possible to mock the android Activity class.

But given that PowerMock allows you to mock classes with final methods shouldn't this code work?

CODE:............

I would think that the RuntimeException would no longer occur and "Title" would be returned but it still throws the exception.

I have tried all sorts of different things like doReturn("Title").when(mockActivity).getTitle(); and suppress(constructor(Activity.class));

Android :: Attempt to stub android Activity class using PowerMockito throws RuntimeException - Stub


Android :: Creating A Stub Of An Activity In Testing Project

Jul 22, 2010

I want to create a stub of one of my Activities, but I want to keep it in the test project so not to have it in the actual apk. I don't seem to be able to find a way to do it though. I get this:

java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.example.test.StubActivity }

I did find if I put it in the main project and put it in the manifest accordingly (IntentFilter:(Action:Main, Category:Default)) it will work, well it actually crashed, but I am not bothered by that. Something to fix later on.I did think about putting everything in the same main project and just have a test package, but that would then involve messing the manifest, I think. It seems better to keep them separate. It's just cleaner.

View 1 Replies View Related

Android :: How To Generate Stub In Phone?

Aug 12, 2009

Hi,Can anyone tell me which tool is used to generate Stub in Android and is it possible to use JAX-RPC concept to call the web service in android.If is it possible please provide me some code with example.

View 2 Replies View Related

Android :: How To Recreate / Re Inflate A View Stub?

Aug 1, 2010

I am trying to recreate and re inflate a View Stub each time an Image Button is pressed because at the moment my app crashes as soon as I press the button a second time (due to a Null Pointer Exception caused by the View Stub that doesn't exist anymore) but I am a little stuck as I don't know how to recreate and reinvokes the View Stub.

View 6 Replies View Related

Android :: KSOAP2 Stub Generator Tool?

Oct 28, 2010

I would like to generate a stub for android. Only one tool is available at "http://ksoap2genstub.sourceforge.net" but i am facing issues with it. java.rmi.remote is not available in android, but this tool generates a class with that. Is anyone know any other reliable tool or a solution of such issues.

View 3 Replies View Related

Android :: Activity - Sometimes - Throws Wrong State Class Exception When Being Resumed After Kill

Nov 24, 2009

I'm testing how my app behaves when killed by the OS due to low memory conditions. I always have three activities on the stack, like: A B C (then C launches maps or some other heavy process)

when my app is killed, and I return to it, C starts itself up again ok. When I hit the back button to go to B, I [sometimes] get an exception thrown which I can't trace. Output is below. I don't know where to go from here. I've only seen one other post mentioning this exception, but it was related to a reproducable error when rotating the device. This only happens sometimes.

CODE:....................

View 12 Replies View Related

Android :: SlidingDrawer Throws RuntimeException In OnMeasure / Set It Up?

Apr 30, 2009

I would like to do some tests on SlidingDrawer however i always found RuntimeException when SlidingDrawer.onMeasure is called i check the code and think the exception is caused by unspecified MeasureSpec

so i would like to ask how to setup the MeasureSpec in SlidingDrawer?

View 2 Replies View Related

Android :: Java.lang.RuntimeException: Unable To Start Activity ComponentInfo

Nov 8, 2010

I wrote an android app and so far it works perfect except for on one phone. It is the exact phone that I have with 2.2 on both phones and mine works perfect. The other phone is getting force close all the time but only when opening an activity that queries my image DB and tries to show a gallery. Every activity crashes in the same place, the viewimages. At first I thought it was the intent that was doing it but one of the activitys does not have the intent, it opens the images below the gallery. This works on the emulator, on my moto droid and on a few other different droids. Here is the code for the gallery and my bitmap decoder.

The error is below that.

CODE:..............

Here is the error

CODE:.....................

View 1 Replies View Related

Android : Starting A New Activity Throws Me Into Debug Mode - Stops App

Jul 22, 2010

I have a listview. Whenever I strike an item of listview the debugger gets opened instead of starting a new activity (i.e. what I want). Code...

P.S. all the xml files are correct.

View 3 Replies View Related

Android :: Communicating Between Receiver Class And An Activity Class

Jul 14, 2010

I'm just getting into Android development, and I have a question about communicating between a receiver class and an activity class. I'm very new to JAVA and Android so I hope I don't sound too stupid. I'm developing an application where I intercept an SMS message and then based on various elements of that SMS I might delete it once it's been saved to the inbox. I have a receiver class that intercepts the txt message, and I am also able to delete messages from my inbox with code in the activity class using a button at the moment. The problem I have is communicating between the receiver class and the activity class where the code to delete a message resides. I tried putting that code directly into the receiver class but as I'm sure most of you already know the BroadcastReceiver class doesn't seem to support what I need to delete messages. I've been searching for an answer to this for a while, but haven't been able to find anything. Honestly I'm not sure I know enough about JAVA and Android to even recognize a solution if I saw it.

View 2 Replies View Related

Android :: Access Application Class From Class Other Then Activity

Sep 8, 2010

I'm new to Java and android development. In my application I need data which is accessible for a few activities. I've read that a good solution is to use Application class for this. So I use it like this:

public class MyApplication extends Application {
private String str;
public String getStr(){
return str;
}
public void setStr(String s){
str = s;
}
}

and I can access this variable from activity like this:........................................

View 2 Replies View Related

Android :: Call Activity Class From Other Java Class?

Oct 8, 2010

I have just started android. I just want to know that how can i call activity class from other java class. i just want to pass class object to activity class.

public class GsonParser extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MagazineThread thread=new MagazineThread();
thread.start();
}
public GsonParser(JsonMagazineParser Obj)
{

}
}

and i am just doing like from other class. GsonParser obj=new GsonParser(this);passing obj to activity class.how can i achieve that.

View 1 Replies View Related

Android :: Start An Activity From Non Activity Class

Aug 19, 2009

An activity can be called from existing activity through *startActivity(intent); *

Is t possible to call an activity from non Activity class ? and how?

View 2 Replies View Related

Android :: Context To Use In A Activity Class?

Mar 3, 2010

I have a class defined as

public class viewGroups extends ListActivity

Somewhere in the class I have

objItem = new clsContactGroups(context);

I am wondering what is advised to be used here? Which context?
I know four choices, but maybe there are others...

this
this.getApplicationContext()
this.getBaseContext()
this.getParent()

I use this Context to show a Toast. So I would like to show on the front-most view visible.

View 1 Replies View Related

Android : Way To Use Intent From Non-activity Class?

Jan 2, 2010

I have three classes one main-activity(named MainMap), one non-activity class(named MyItemizedOverlay), and one activity class(named AudioStream). I want to start AudioStream activity from non-activity class but i don't know how to.

View 1 Replies View Related

Android :: Starting An Activity From Callback Class

Aug 18, 2010

I have an activity class(Application Class ) which calls a service class(Service Class) and closes. The service class takes about 5 seconds to complete its task and calls a method which is present in another class(Callback Class). Now according to the result, the callback needs to notify the Application class.Once i get the callback from the service, I tried calling a method defined in the Application class. In this method i create a new intent of Application class and call startActivity(Application Class). But this is not working. Can anyone tell where i am going wrong and what can I do to solve this issue.

View 5 Replies View Related

Android :: Tabhost Working In Activity Class

Nov 17, 2010

I must be overlooking something because I am unable to get my TabHost to display in my Activity class.I am getting the dreaded force close when I try to run the app.It will work if I extend TabActivity, but I can't do that [details at the bottom] because once I move the code from my prototype project its going to be in a custom class that inherits from Activity.

View 2 Replies View Related

Android :: Call TextToSpeech In Your Class - Not In Activity

Aug 16, 2010

I wrote successfully TTS with some references in Activity.

However, I want to call this TTS in my own class as below.

CODE:............

View 3 Replies View Related

Android :: How To Get Method Of Listactivity From Activity Class?

Apr 19, 2009

Can i call method of Listactivity from Activity class? I have creates Intent object of myListActivity class and called startIntent() from myActivity class.

View 3 Replies View Related

Android :: Launching Intent From Class Outside An Activity

Jul 28, 2010

I've got two activities, one of them is called MyActivity. I want both of them to be able to use a function located in a class othat we may call MyClass. In MyClass, I try to use an intent to launch the activity AnotherActivity. Since the constructor takes a context as parameter, I simply tried to store a context from the activity in the constructor, and then use it when I try to create my intent.However, even thought none of the arguments are null (checked that with a simple if-statement), intent seems to be null and a NullPointerException is thrown. Why does it not work, and what can I do to solve the problem?
I'm quite new to Android and Java development, so please explain it as basic as you can.

View 2 Replies View Related

Android :: Static Database Class To Use With Any Activity

Jan 5, 2010

I am new to Android, and I haven't developed any app regarding databases on Android yet. So I have a few basic questions. I am after a good database class sample, that will let me to run the CRUD operations. I would like to use it as a static class

like: clsDB->Select("select * from clients");
or objClient->Delete(clientid);

I am wondering if someone, can share his database classes, if more people share the best. Also I have in mind to reuse this class in multiple ways, I will have services, activities etc...

View 4 Replies View Related

Android :: Starting An Activity From A Random Class

Sep 18, 2010

I've adapted the GridInputProcessor-class of the 3D-Gallery ( http://android.git.kernel.org/?p=platform/packages/apps/Gallery3D.git;a=blob;f=src/com/cooliris/media/GridInputProcessor.java;h=91dfd4783be6b21ec8ff2518a5c244752570e90d;hb=HEAD ) so that it detects upward/downward swipes.

The detection of swipes works, but I now want to start another activity (or draw a bitmap on the currently displayed activity), but I seemingly can't use startActivity(mContext, myIntent), because the class declaration is public final class GridInputProcessor implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {so it doesn't extend Activity...

Can I still start an Activity through this class, or how would I go about doing this? I have also tried sending a broadcast, but this is also not "implemented".

View 1 Replies View Related

Android :: Way To Start Activity In Receiver Class

Nov 18, 2010

This is vinod i have been saving problem while i am starting Activity in receiver so i would know this is the way or not for start activity in receiver

View 3 Replies View Related

Android :: Start An Activity From A Non-context Class?

May 4, 2010

For example, I have an activity that uses a utility class. I would like to be able to start an activity from the utility class and have the activity result sent back to the utility class.

The only way I could think of starting the activity was to pass the original activity to the utility class, so that the utility class could use the original activity to start the activity. The problem with this is that the activity is sent to the original activity, rather than the utility class.

I also thought of actually making the utility class an activity itself, but that would make using the utility class much more complicated.

View 10 Replies View Related

Android :: Call One Activity From Dialog Class?

Mar 12, 2010

How to can call one activity from Dialog.

View 3 Replies View Related

Android :: Example To Use Class SingleLaunchActivityTestCase <T Extends Activity>?

Aug 2, 2010

I am quite new to Android and Java
I am looking for example of how to use this class:

SingleLaunchActivityTestCase

Till now I am using class InstrumentationTestCase but the problem is that for each launched test case Android calling onSetup() and TearDown()

View 2 Replies View Related

Android :: Possible To Retrieve Contacts Without Using Activity Class?

Nov 24, 2010

Is it possible to retrieve the contacts without using Activity class?

I'm using LWUIT for developing android application. I need to retrieve the contacts from android phonebook. How its possible?

Because normally retrieve contacts process achieved in inside of extend Activity class. ( I seen some examples).

In LWUIT, They created own Activity class.
So i need to achieve some other class not in activity class.

How its possible?

View 1 Replies View Related

Android :: Use Ui Api In Other Class And Thread Expect Activity?

Jun 24, 2010

I have some questions about android ui api.

Give a example, that I want to implement.

Main_UI_Thread.java. code...

I know the message passing can be do that;

But I want the ui program is be implemented in DisplayClass.java. Is it possible?

View 1 Replies View Related

Android :: Create A Class Which Not Extended Activity?

Sep 23, 2010

How to create a class which not extended Activity & how can i use it class?

View 1 Replies View Related

Android :: Difference Between File Class And Activity

Aug 17, 2010

What's the difference between file, class and activity in android?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved