Android :: Detect If A View's Parent Activity Is Paused

Jun 20, 2010

In one of my Activities I have a ListView that displays a list of locations. For each list item I want a little arrow icon that points in the direction of the corresponding location. I implemented this icon by extending ImageView. This custom View has a listener that reacts to changes of the device's orientation by rotating the icon image accordingly. I register the listener in the onAttachedToWindow() method and unregister it in onDetachedFromWindow(). This kind of works but the problem is that onDetachedFromWindow() sometimes gets called only a long time after the containing Activity has paused. Also, the whole layout overall seems a little hacky. So my question is: Is there a proper way to unregister the listeners or would you implement this in a completely different way to begin with?

Android :: Detect if a View's parent Activity is paused


Android :: Detect If View's Parent Activity Is Being Destroyed?

Jun 30, 2010

I want to do some cleanup in a view when the activity is being destroyed. Is there any way to get a callback in the View when the activity is being destroyed? I tried using onDetachedFromWindow, but I'm not sure whether it is correct thing to do.

View 1 Replies View Related

Android : Way To Handl Key Events In A Paused Activity?

May 4, 2009

A main task and a secondary task - the secondary task has only one Activity - when that Activity is paused (e.g. Home key pressed), a notification is inserted to the Notification Bar, so that the user can go back to it (such as voice call does) My problem is: I need the paused Activity to receive key events. 1) Is that possible? 2) If so, how? (I have already tried setting "takeKeyEvents(true)", but whenever I press a key, the "Bookmarks" activity comes to the foreground)..

View 17 Replies View Related

Android : Pass Data From Current Activity To Paused One?

Dec 20, 2009

I wanna know how to pass data from current Activity to paused Activity?

View 3 Replies View Related

Android :: Adding Child View At Particular Location In Parent View

Mar 20, 2010

I need to draw a child view containing a rectangle and button on top of the content view at particular location on the parent (content view). How can I do this? Did not find an explicit way to set origin of child view?

View 1 Replies View Related

Android :: How To End Child Activity And Return To Parent Activity?

Jul 25, 2010

I have a main screen with buttons to launch other subactivities. I have to press back button each time to go back to the main screen of my application. How do I finish a child activity and automatically return from the caller?

View 5 Replies View Related

Android :: Activity Parent - Created Activity Returns A Nul ?

Apr 7, 2010

Can someone tell if why when starting an activity with startActivity(intent) , calling getParent() in onCreate() of the new created activity returns a nul ?

Also how could I obtain the parent of an activity created in such a way ? Can a reference of the activity below the current activity in the activity stack be obtained ?

View 2 Replies View Related

Android :: BringtoFront The Parent Activity?

Sep 7, 2010

As we know, startActivityForResult() used to get a result for a task from parent activity. Here when we click the setResult(). It returns the result to the parent Activity.

Child Activity means it should maintain the persistent state. That is when the users clicks a button on the child activity. It do not finishes that activity and show the Parent Activity. And again i may go to the child activity from parent activity. If the child does not exists it starts a new child activity else it should show the existing child activity with persistent content.

Simply said, my parent Activity starts a new Child Activity. Now both Activities should be alive. How to call the Parent Activity without finishing the child Activity(in other words, How to BringtoFront the parent Activity)? For this scenario,

you can not use startActivity(). Because it creates a new Activity Instance. Not Existing Parent Activity
you can not use startActivityForResult(). Because it finishes the child Activity Instance.

View 2 Replies View Related

Android :: Size A View Based On Its Parent's Dimensions?

Jan 29, 2010

How can I size a view based on the size of its parent layout. For example I have a relativelayout that fills the full screen, and I want a child view, say an imageview, to take up the whole height, and 1/2 the width? I've tried overriding all on onMeasu onLayout onSizeChanged etc and I couldn't get it working....

View 3 Replies View Related

Android :: Back To Parent View When Press On Escape

Dec 29, 2009

I am using ViewFlipper for my application. I trying to make it.when user pressed on escape (back) button, it would be back to parent Layout.

View 3 Replies View Related

Android :: How To Access An Element Present In Parent View

Oct 20, 2010

Full code. how do i access the parent activity's mail layout elements? In this case a button. I have it declared in main.xml. When a button in the listview is clicked, i want to change the text of the button in main.

View 1 Replies View Related

Android :: Finish Parent Activity From Child?

Mar 30, 2010

My child activity X is called from Parent activity P through startActivity(intent). I want to close P when X called its finish() method. I override a method finishFromChild(Activity child) in P and called finish() in it. But this functions (finishFromChild(Activity child)) is not being called after X finish() Is it a known bug or I am missing some thing? I googled and also searched the groups but no help.

An alternative could be... using StartActivityForResult() and a "fake" onActivityResult, where I can finish the parent activity, but this way is quite bad, i think...

I prefer the first one, if it would work....

View 3 Replies View Related

Android :: Activity That Does Not Fill The Parent Screen

Dec 14, 2009

Any idea why this doesn't create an activity that looks like a popup instead of an activity that completely fills the screen?

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

I assumed that I only needed to set the layout height and layout width to something other than "fill_parent", but it still shows up as a black screen that completely fills the screen.

Ultimately, I simply want to create a popup, but I do not want to use an AlertDialog. Is this possible?

View 2 Replies View Related

Android :: Parent And Child Activity OnCreate?

Jul 2, 2010

I have a parent activity, and a child activity that extends the parent activity. When the parent starts the child activity,

Which onCreate gets executed first? The child's or parent's?

There is a particular variable I am setting in the Child activity's onCreate method, and right now, it looks like it takes a while to get to the Child activity's onCreate, and so the methods in the Parent are reporting an empty variable. Whereas when I make the Parent sleep for a while, it reports the correct variable.

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

So, basically, even after the Parent starts the Child, it still returns "Parent Value", but when I have the thread sleep, it return "Child Value".

View 1 Replies View Related

Android : Use Data Passed From Parent Activity In A Sub?

Jun 28, 2010

When we want to pass data from an activity to a sub activity we use the is there any event handler that handles this?

View 1 Replies View Related

Android :: How Do I Center A Grid View In Its Linear Layout Parent?

Oct 9, 2009

GridView is not behaving like it is supposed to.
This screenshot shows that the GridView (in landscape mode) is flushed left.
I want it centered. This is the XML layout for the GridView.
<Linear Layout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/templatelandscape"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<GridView
android:id="@+id/commandsbarlandscape"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:padding="0dp"
android:verticalSpacing="2dp"
android:horizontalSpacing="2dp"
android:numColumns="auto_fit"
android:columnWidth="52dp"
android:stretchMode="spacingWidth"
android:gravity="fill_horizontal">

View 2 Replies View Related

Android :: Want To Open New Child Activity In Parent LinearLayout

Nov 8, 2010

I want to open new child activity in the parent LinearLayout. Just similar like Tabs.

View 1 Replies View Related

Android :: Return Back To The Parent Activity From Subactivity

Jun 14, 2010

My application supports twitter and needs to open browser for OAuth. When the user clicks the Share on Twitter button, the main activity will create another subactivity (TwitterActivity) to handle twitter authentication issues. Here is a flow graph showing how activities are invoked currently. Main is short for MainActivity and Twit for Twitter Activity. startActivity() OAuth intent OAuth callback finish()Main ---------------> Twit ------------> Browser --------------> Twit --------> Browser As you may notice, after the TwitterActivity calls finish() to stop, it will now return back to MainActivity, but Browser instead. How can I make it return back to MainActivity?

View 2 Replies View Related

Android :: Picking A Contact And Returning To The Parent Activity

Jan 28, 2010

I wish to re-use the Contacts application in a way to enable the user to pick a contact and return it to the parent activity (my application's activity).

For achieving this, I want to inquire about the kind of Intent that will be needed to launch the contacts application.

Intent i = new Intent(Intent.ACTION_GET_CONTENT, ?); startActivityForResult(.....);

What should be the second argument here ?

In the deprecated Contacts API, I could use the following snippet, but not sure about ContactsContract:

Intent i= new Intent(Intent.ACTION_GET_CONTENT,People.CONTENT_URI); startActivityForResult(i, reqCode);

View 3 Replies View Related

Android : Lifetime Of Background Parent Activity After StartActivityForResult()?

Jul 19, 2010

Is there an exception in the lifetime rules for a parent activity that's in the background after invoking startActivityForResult()? From my understanding, in low memory scenarios, the background activities are killed before the foreground. Does this rule still apply even if the background activity started the foreground one for the purpose of obtaining some result?

In this case, I think it would make sense for the foreground child activity to get killed first or to equalize the lifetime of the parent and child.

View 5 Replies View Related

Android :: SingleInstance Of The Activity And Relay Information Back To Parent?

May 8, 2009

I basically have three activities X, Y, Z and I want only one instance of each but I want control over the navigation and I can't do that by putting all three activities in one task because of the stack structure.

Here is a scenario, from X I launch Y given a certain "id" which correspondence to specific data in the DB, Y inflates and populates it's views, then I go back to X and launch Y again with a different "id" in the intent, I don't want the overhead of launching the activity and inflating the views again, anyone know how to do this?

I tried using singleInstance, but the problem is that I can't send the result code back to an activity in a different task.

View 4 Replies View Related

Android :: Parent Activity Runs OnCreate Before OnActivityResult Is Called - Sometimes

Aug 5, 2010

The order is:

A: startActivityForResult( B ) B: <dostuff>, call finish() A: onCreate <---- what's this all about A: onActivityResult

This happens for a tiny minority of users. I havn't been able to reproduce or find any common elements. A is the launch activity.

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

View 7 Replies View Related

Android :: Create A Single Class Which Can Be Parent For Every Type Of Activity?

Oct 7, 2010

I wish to have a single class which all of my Activity classes extend. I have ListActivities, Activities, MapActivities, TabActivities, etc in my App.

I have many of these different activities in my app, ~12 activities. I want each of them to have the methods which are in the parent class.

Right now, i have created 4 parent activity classes which are extended from a certain activity depending on their type(ListActivity, Activity, MapActivity, TabActivity)

I am creating a lot of redundant code - each of the 4 parent activities has almost identical code, in exception for what class activity it extends.

Here is an example that may clarify what my problem is:

I have an Activity: MenuScreen which extends BaseListActivity BaseListActivity extends ListActivity BaseListActivity contains methods and fields which i want all my activities to have access to I have another Activity: HomeScreen which extends BaseActivity BaseActivity extends Activity BaseActivity contains the same methods and fields which are in my other Base[<type>]Activity classes(such as BaseListActivity)

These methods/fields are copy-pasted to all my Base[<type>]Activity, and seems awfully redundant to me.

Can i create a master activity class which all types of Activity classes can use as its parent? if not, am i stuck with copy and pasting this code and feeling gross/dirty about it?

View 2 Replies View Related

Android :: View Stops Receiving Touch Events When Parent Scrolls / Continue It?

Sep 8, 2010

I have a custom Android view which overrides onTouchEvent(MotionEvent) to handle horizontal scrolling of content within the view. However, when the ScrollView in which this is contained scrolls vertically, the custom view stops receiving touch events. Ideally what I want is for the custom view to continue receiving events so it can handle its own horizontal scrolling, while the containing view hierarchy deals with vertical scrolling.

Is there any way to continue receiving those motion events on scroll? If not, is there any other way to get the touch events I need?

View 1 Replies View Related

Android : Forward Activity Result To Parent With SingleTop Launch Mode?

Jun 1, 2010

I have two activities: a MainListActivity, and a DetailViewActivity. DetailViewActivity is set with android:launchMode="singleTop".

When clicking an item in the "main list" activity, it launches the "detail view" activity via:

startActivityForResult(detailIntent, REQUEST_CODE_DETAIL);

If I then call setResult(RESULT_OK, resultData); and finish(); from within the Detail activity, that resultData is received by the "main list" activity's onActivityResult(..) method correctly.

However, if I implement a "see previous"/"see next" type of navigation within the Detail activity, and implement it using singleTop, that result no longer gets sent back to the initial activity:

Intent nextItemIntent = this.createIntent(nextId);
nextItemIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(nextItemIntent);
// at this point, my DetailActivity's onNewIntent() method is called, and the new data is loaded properly

But from here, when I call setResult(..) and finish(), my MainList activity never receives the new/updated result. Anyone know what I'm doing wrong?

View 1 Replies View Related

Android :: FinishFromChild And OnActivityResult Not Firing When Child Starts Activity Of Same Type As Parent

Jun 8, 2010

I have an application, which (for the sake of simplicity) has two types of activities - Overview and DetailView. The Overview activity shows a list of steps and allows the user to start a DetailView activity corresponding to the step chosen.

In the DetailView activity, the user can start another Overview, which shows different steps than the ones in the parent of the current DetailView.

In the Overview, DetailView is started by using startActivityForResult (). In the DetailView, when the user decides to start a second Overview, I call setResult () and finish () and then start the new Overview. In this scenario, onActivityResult () and finishFromChild () do not fire. Instead, they fire when the parent finishes (?).

Code from Overview:

CODE:....

Code from DetailView:

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

View 1 Replies View Related

Android :: Detect Triple Tap On View?

Jul 20, 2010

I haven't spend much time on Gesture Detector or anything of that sort.

My requirement is very simple, Given a View (any view), how do I detect triple tap on that?

Of course a timer and a counter can help me, but I am looking for something more sophisticated that that.

For people, you are wondering, why I need triple tap, I am introducing a hack screen in an application (which I am porting from IPhone and IPhone does it that way, so I have to do it.

View 5 Replies View Related

Android :: How To Detect Doubletap On A View

Apr 14, 2010

I'm trying to have a View sensitive to double taps on an Android. So far, I learned to set up the double tap and know what place to handle the event for action code...

But How do I link it to the View? This is in a class that has a few View members.

View 1 Replies View Related

Android : Way To Detect Event From Web View?

Jan 26, 2010

I am developing an application which requires cancellation survey when user tries to deactivate application service. Cancellation survey i am using the third party survey software http://wufoo.com/gallery/templates/surveys/cancellation-survey/. I am able to render the survey (third party html) web view in my activity.When ever the user presses submit button on WebView, activity need to store the status of survey(like user successfully submitted or not). Is there any way to detect the event from web view?

View 3 Replies View Related

Android :: Detect When User Taps On View?

Jan 10, 2010

I want to detect when a user taps anywhere in a view in my Android application. My code looks like this:

linearLayout = (LinearLayout) findViewById(R.id.linearLayout); // main layout
// ...
linearLayout.setOnTouchListener(this);
// ...
public boolean onTouch(View v, MotionEvent event) {
Toast.makeText(this, "Touch!", 1000);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
Toast.makeText(this, "Down!", 1000);
return true;
}
return false;
}

but when I click on the view, I don't get Toast! Do touch events work in the emulator -- or have I got something wrong in my code?

View 2 Replies View Related







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