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.?

Android :: How can I get current Activity object in Instrumentation object?


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 :: 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 android.app.Instrumentation.validateNotAppThread(Instrumentation.java: 1427)
04-27 16:12:16.720: ERROR/AndroidRuntime(4406): at android.app.Instrumentation.sendKeySync(Instrumentation.java:857)
04-27 16:12:16.720: ERROR/AndroidRuntime(4406): at android.app.Instrumentation.sendKeyDownUpSync(Instrumentation.java: 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(); }

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 Current Layout Object?

May 4, 2009

I create a application and the main activity reference by the main.xml. The main.xml has a LinearLayout element. So my code is setContentView (R.layout.main) to show the main window.I need add other element such as Button or EditView, but I don't want add the XML line to the main.xml.I hope use the layout.addView(...) to add the elements to my Activity. So I need get the current LinearLayout object and can invoke the addView function. So How can I get the default layout?

View 3 Replies View Related

Android :: Want To Get Current Focus View Object In Service?

Nov 18, 2010

I want to get the current focus view in my Service to check the view is a EditText and append some texts in it (for all EditTexts, not only in my application).

I found some methods to do this, like Activity.getCurrentFocus() and Windows.getCurrentFocus(). But these methods are used in a Activity.

How can I use these methods in a Service? Or is there another way to do?

View 2 Replies View Related

Android :: Set Activity Object To Application?

Apr 26, 2009

When start the activity i will set the activity object to the Application, and i will registry it in the Appication app = MyApplication.getApplication(this);

1. Start Activity A store A id 0x12345678
2. Activity A -> Activity B
3. Store B id 0x87654321
4. Finish B activity
5. but the Activity B object not null in the Application

View 7 Replies View Related

Android :: Get KeguardScreenCallback Object In My Own Activity?

May 25, 2009

Is there someone could tell me how to get the KeguardScreenCallback object in my own Activity(For Example,the class of LockScreen,it has a parameter called "callback" in it's constructor,I want to get the "callback" in my activtity).so I can call the goToUnlcokScreen method to remove the screen lock.Or there maybe other way to do this?(I know KeyguardManager,so except this way first.

View 2 Replies View Related

Android :: Pass An Object From One Activity To Another?

Aug 28, 2009

I have an activity which implements an OnItemClickListener.code...

However, I need to pass some objects from MyActivity1 to MyActivity2 --

I see there is an Intent.putExtra() for all the basic types, and I even see a Bundle which is a collection of basic types, but how can I pass a generic "Object" to MyActivity2 ?

View 3 Replies View Related

Android : How To Pass Object From An Activity To Another

Oct 15, 2009

There is an activity which has an object. This activity(say A) starts another activity(say B). Can B use some object in A?

View 7 Replies View Related

Android :: Get Activity Object While In View Context

Oct 10, 2010

This is a followup to this post: http://stackoverflow.com/questions/3897176/findviewbyid-in-a-subclassed-surfaceview-throwing-runtimeexception Based on Romain Guy's feedback (which I'll accept shortly as it is a solution), I'd like to obtain the calling Activity from within the View, so that I can use it to obtain the desired Text View resource. I don't see any methods in View that return Activity. What is the proper way to do this? Or is there a better alternative for working with TextViews from within another View context. Basically, I am calling setContentView(R.layout.xxx) in onCreate() (as usual), so I don't really have a way to pass in references to additional TextViews unless I awkwardly retrieve the View after setContentView and then make calls on it.

View 1 Replies View Related

Android :: How To Pass A Bitmap Object From 1 Activity To Another

Mar 17, 2010

In my activity , I create a Bitmap object, and I need to launch another activity,
How can I pass this Bitmap object from the sub-activity (the one which is going to be launched)?

View 1 Replies View Related

Android :: Way To Pass An Object Array To An Activity

Nov 15, 2010

I have read posts on passing arrays from and to activities, but I am confused as to how I would do it for my specific case.

I have an array of objects called DaysWeather (a DaysWeather[] array) where the objects have several String attributes as well as a bitmap attribute. I read somewhere that you have to make it serializable or parceable or something, but it seems messy at first glance.

Could someone lead me in the right direction?

Is there a simple way to do this?

View 1 Replies View Related

Android :: How To Pass An Object To An Activity Via Intent.putExtra?

Aug 7, 2009

I am developing an app that connects to a server. For that connection I created a class Client that maintains info about the connection . My app consists of several Activities and each of that Activity needs access to the Client object to communicate to the server. 1) Can I put somewhere the Client object so that all Acitvities have an access to it? 2) If not I would probably need to pass the object to each Activity via Intent.putExtra(). But putExtra doesn't accept Object as an argument. It only accepts several types like int, long, String etc. So how can I pass an object to another Activity?

View 2 Replies View Related

Android :: Why Is Parcelable Object Null In Receiving Activity?

Aug 16, 2010

I am following the Parcelable example in the Android developer guide with the intention of having a more complex object that I send to different activities. Right now, my class is a wrapper of a String member. If I put the object in the intent and read it back from the Intent it reads as expected, however, on the receiver side, it is always null-pointer.

View 1 Replies View Related

Android :: When Does Activity Object Really Get Killed After Calling Finish()

Nov 5, 2010

I created a thread in my activity, and that thread will print out the value of my instance variables in my activity after running for about 10 seconds. I pressed the back key to destroy my activity before the thread prints out the values, and when the thread reaches that line of code, it can still print out the values correctly. That means even though the activity is finished, the java object of the activity is still there. Will the object always be there? Or it is just waiting to be GCed? Or it will be killed only when Android needs memory?

View 2 Replies View Related

Android :: Invoke Changes To A Custom View Object From Its Activity?

Nov 7, 2010

I have a custom view that draws to a canvas. I am trying to invoke changes to the canvas when the user pushes a button from the activity that this view is tied to. Currently, I am attempting to do this by calling a public method, called setNewDrawable, that I created inside the view.

The debugger is giving me different values for the view ID depending on whether I'm inside setNewDrawable or inside the Overridden onDraw method when I post an Invalidate.

For example the debugger variables show: (This - MyView id=830067720176) or (This - MyView id=830067712344) in setNewDrawable and onDraw respectively. This makes me think I basically have two copies of the object and I am essentially interacting with the wrong one.

How can I get information to my custom View in order to determine what it draws?

Here is the code I am running...

View 1 Replies View Related

Android :: Getting Error / Pass Activity Object To My New Class?

Mar 26, 2010

I want to show messageBox or notification when connection lost in Static DB class but i cant use getApplicationContext() because its a static class and i tried to call other class called notification but i have error so how i could pass activity object to my new class .

View 3 Replies View Related

Android :: Share An Object Between A Running Service And Activity?

Aug 8, 2010

I have an API Object that I made, and I would like to share it between a running Service and various Activities in my app, almost like if I was to make the class static. How could I go about sharing the created object between the two?

View 2 Replies View Related

Android : Create A Surface Object Without A Foreground Activity

Jul 6, 2010

I have a function that needs a Surface object to work. I'd like to be able to call that function from a background Service without starting a foreground Activity. Every Surface source in the API that I can see, though, requires a View that's laid out before the Surface becomes available. Are there other ways to create a Surface that I am missing, and can you point me to them?

View 5 Replies View Related

Android :: Cannot Call Method Of View Object Inside Activity

Nov 7, 2010

In my program I have a custom view object. Inside the view class is a method called foo. For some reason when I call foo from my activity, it doesn't fire. Here is the code:

XML of the custom view:
<com.company.application.MyView android:id="@+id/my_view" android:layout_width="wrap_content" android:layout_height="wrap_content" />

The activity code:
public class Main extends Activity { MyView mView;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.main);
LayoutInflater li = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = li.inflate(R.layout.main, null); mView= (MyView) v.findViewById(R.id.my_view);
//A button to fire the method inside foo() Button switchLeft = (Button) findViewById(R.id.switch_left); switchLeft.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { callTest(); } } );
} public void callTest() { Log.w(this.getClass().getName(), "clicked left arrow");
mView.foo(); mView.postInvalidate();
} }

Finally here is foo:
public void foo() { mBackground = mContext.getResources().getDrawable(R.drawable.temp_canvas); Log.w(this.getClass().getName(), "background set");
}

The first log is always written when the button is pressed, but the second log is not because foo never fires. What is the deal here? Upon request, the full view

public class MyView extends View { Drawable mBackground; Context mContext;
public MyView (Context context) { super(context); mContext = context;
mBackground = mContext.getResources().getDrawable(R.drawable.leftarrow1);
} public MyView (Context context, AttributeSet attrs) {
super(context, attrs); mContext = context;
mBackground = mContext.getResources().getDrawable(R.drawable.leftarrow1);
} public void foo() { mBackground = mContext.getResources().getDrawable(R.drawable.temp_canvas);
Log.w(this.getClass().getName(), "background set"); }
@Override public void onDraw(Canvas canvas) { Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL); // draw a solid blue circle
paint.setColor(Color.BLUE); canvas.drawCircle(20, 20, 15, paint);
// draw a test background mBackground.setBounds(0, 0, 300, 400);
mBackground.draw(canvas); }
}

View 1 Replies View Related

Android :: How To Send Object From Droid Activity To Another With Intent.putExtra?

Nov 24, 2010

Can anyone guide me as to how I can pass an object of a custom type from one Activity to another with the putExtra() method of Intent?

View 5 Replies View Related

Android :: Pass User Define Object Between Service And Activity?

Aug 21, 2009

I define a class Rect and a aidl file as below. code...

View 2 Replies View Related

Android : Way To Get Hashtable Object Form A Class To Activity In Droid?

Feb 23, 2010

I want to get the hashtable object from non activity class to activity class an android..

View 1 Replies View Related

Android :: How To Clone View Object / Can Be Added To Current View Hierarchy?

Feb 28, 2010

I like to know how can i clone a view object which is already there in the view hierarchy, so that it can be added to the same view hierarchy again.

View 1 Replies View Related

Android : Convert Android.net.Uri Object To Java.net.URI Object

Feb 18, 2009

I am trying to get a FileInputStream object on an image that the user selects from the picture gallery.

This is the android URI returned by android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI content://media/external/images/media/3

When I try to construct a java URI object from this object, I get an IllegalArgumentException with the exception description Expected file scheme in URI: content://media/external/images/media/3 whereas the android URI shows the scheme as content

Never found a solution for the original question. But if you want the byte stream of an image in the pictures gallery, this piece of code will do that.

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

View 4 Replies View Related

Android :: Get URL From Cursor Object

Jun 16, 2009

I have a Cursor points to a Contact. How can I get an url built from that Cursor?

I need to know that because from here: http://developer.android.com/guide/topics/providers/content-providers.html

I need to have an url so that I can build a phone uri, like this: phoneUri = Uri.withAppendedPath(uri, People.Phones.CONTENT_DIRECTORY);

and I can query all the phone numbers for that contact.

View 1 Replies View Related

Android :: Does An App Only Have One Context Object

Jul 19, 2010

I'm confused about the concept of the Context class. I see that it's a base class of Activity, but the Android docs also mentions the Context storing global information about the app environment. So in my app which has 3 activities, does that mean I have 3 distinct Context objects, or do they actually refer to 1 entity? Also, what is the lifetime of a Context object- does it live until the last component of this activity's process is garbage collected?

View 1 Replies View Related

Android :: Not Dragging Of Object

Feb 5, 2009

I want to get drag event(s) when user holds finger on screen and drags it in any direction. The event need to repeatedly provide new touch position until finger is released in the form of callbacks. This is not related to dragging objects.I could see this drag feature working on home screen of the phone to move the home screen left and right. But couldn't figure out how it works. Please provide information on which class and methods to be referred for this.

View 2 Replies View Related

Android :: Get Object From Webview

May 19, 2010

I want to get the object from the webview how to do it ?

View 3 Replies View Related







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