Android :: Finish Activity From Custom BaseAdapter

Nov 22, 2010

In my android application I have custom listview with an image and textview. In extended BaseAdapter under getView method click events of textview and image are associated with onClick method using setOnClickListener as shown in code below

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

And

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

When clicking on image it acutally deletes that entry from List which works fine, but on clicking textview i would like to return the text of clicked textview to main activity but I am unable to achieve this, although I can do this from setOnItemClickListener of this custom listview acitivity.

Android :: finish activity from custom BaseAdapter


Android :: Activity Finish Method Waits To Finish?

Aug 14, 2010

With this sample code, the activity is told to finish, but continues execution afterwards and displays the message. I'm trying to understand why this happens. The only fix I can think of is to place 'return' after finish.

public void someMethod() {
if( valueIsTrue) {
startActivity(new Intent(this, NewActivity.class));
CurrentActitivy.this.finish();

// return; // if uncommented, Toast doesn't show
}
Toast.maketext(this, "Some message", Toast.LENGTH_SHORT).show();}

View 1 Replies View Related

Android :: Custom BaseAdapter - Dynamic Updates - Crash In ListView Layout

Feb 16, 2010

I'm trying to get my first Android app stable enough for the marketplace, and I've hit a brick wall with one exception that I don't understand. Probably I'm doing something stupid, but I can't tell what, and after several hours googling and experimenting, I thought I'd see if I can get some help. My Activity extends ListActivity, and the parts I think are most important are extracted below:

GroupedListAdapter is a simple class that extends BasedAdapter to provide headings for sections of the list (not unlike the Fancy ListView tutorials that are floating around).

I create this in onCreate, and it works fine. Inside onListItemClick, I do some actions which will create a different set of list contents. I "clear" the adapter, which empties the contents, and call reload, which repopulates it. Then I call notifyDataSetChanged.

Most often, this seems to work, but also fairly often, I get the exception following the code snippets below - this seems to indicate the ListView is not in sync with my changes. Lately this crash happens 100% of the time under the simulator.

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

View 8 Replies View Related

Android :: Custom ListAdapter Extending BaseAdapter Crashes On Application Launch

Mar 23, 2010

Data being pulled from a local DB, then mapped using a cursor. Custom Adapter displays data similar to a ListView. As items are added/deleted from the DB, the adapter is supposed to refresh. The solution attempted below crashes the application at launch.

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

Errors:

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

View 3 Replies View Related

Android :: Finish Any Previous Activity In Stack From Current Activity?

Apr 27, 2010

How to finish any previous activity in application stack (at any level , I mean not immediate parent) , from current activity like on some particular event I want to invalidate this previous activity?

View 1 Replies View Related

Android :: Finish Activity Not Started From Current Activity

May 1, 2010

I have following problem with my application: From my main activity ("activity 1"), there is a menu from which user can launch an action. This action will result in an Intent being received by a BroadcastReceiver, defined in my application. Finally, this BroadcastReceiver will start an activity ("activity 2") to deal with this intent.

The problem is that I have a "quit application" entry in my menu, and I can only finish() currently active activity. ie I am not able to finish "activity 1" from the menu of "activity 2". And I can't use startActivityForResult() as "activity 2" can't be started from "activity 1". Any suggestion would be much appreciated Thank you very much guys, regards.

View 4 Replies View Related

Android :: Finish Activity From Other Activity

Oct 8, 2010

I am having application in which i am using menu , on tap on menu item i am redirecting to specified activity. I want to make sure that when i am redirected to another menu item my current all activity should be finished to reduce the stackflow of the activity and better performance. So when i tap on back from my tapped activity from the selected menu activity i should be redirected to another activity and finish current activity. So i am wondering is there any way by which i can finish another activity from my current activity. Or should i override the OnKeyDown Method..

View 1 Replies View Related

Android :: How Finish An Activity In This Instance

Aug 16, 2010

We all know that hitting the back button on the device doesn't kill the application, it merely finishes (destroys) the activity running on the foreground.

Well I have come across some code which helps me capture the back button signal so that I cannot exit the application. The only way to exit it in such cases is to press the home key.

Now this situation presents me with a unique disadvantage! The inability to kill finish the application on a time of my own choosing allows the application to keep running in the background like nothing has changed.

So in such cases is the task manager my only friend or is there a way for me to otherwise kill this application?

View 2 Replies View Related

Android :: Activity Pause Rather Than Finish?

Nov 30, 2009

I see no means by which my activity can pop itself off the activity stack to return the user to the one he was using before it was invoked. Is there one? My purpose is that my app has some data structures built from data provider queries that take 5-15 seconds to assemble and I don't want a lot of latency if it is used in a few one-shot purposes in rapid succession. I'm more than willing to let the system ask my app to die, but I'd like to keep warmed and ready otherwise.

View 4 Replies View Related

Android :: Wait For Activity To Finish?

Sep 7, 2010

I have one activity call a camera view activity, and in the onActivityResult, I have it start that activity again with different parameters. Android doesn't seem to like that, and gives me an error that the camera is not available if I start it right after it returns. I tried just waiting a few seconds, but this doesn't seem to work on all phones, and it sometimes crashes. Is there some way to wait until that activity finishes properly, and gives up all resources?

View 6 Replies View Related

Android :: Finish Not Killing Activity

Apr 12, 2009

I've got an application that has (among other things) three Activities, let's call them A, B, and C. A is the main navigation point for the entire application, and launches B and C directly using startActivity(). They work fine that way. However, when I call C from inside B, I get a strange problem. The code for launching Activity C is exactly the same in both places. The problem is the hardware back button. In the emulator, it takes two presses of the back button in order to close Activity C and come back to B. On a G1, it takes 3 or 4 presses. Upon seeing this, I implemented the usual suspects in C - onPause(), onStop(), and onDestroy(), and onResume() in B. When I press the back button from C and it doesn't work, I get onPause(), onStop(), onDestroy () - in that order, but nothing happens. When it works (on press 3 or 4 on the G1), I get onPause(), then onResume() in B, then onStop() and onDestroy().

I've tried catching the key press of the back button and calling finish (), but that doesn't make a difference. Has anyone seen this? To pre-empt some questions: All C does is display some data. There are no threads or any other special resources that C might have an active handle to that's preventing it from closing. But out of curiosity, if it did, how would I detect that? Any ideas for further diagnostics here?

View 12 Replies View Related

Android :: Finish() Won't Close Activity

Jul 23, 2009

I have an EditText field and I want to pop up a new window/activity whenever a user touches/clicks the field. The new window has some widgets and of course Apply and Cancel buttons. Here is the code how I intercept the onTouch event.

EditText ctlMaskEt = (EditText)findViewById(R.id.mask_field); ctlMaskEt.setOnTouchListener(new OnTouchListener() { public boolean onTouch (View v, MotionEvent event) { popMaskEditor(); return true; } });

Everythings work fine until I click the Apply and Cancel buttons. The API finish() won't close the new window unless I click the same button one more time. Calling popMaskEditor() from a button's OnClick event handler doesn't have this problem.

View 2 Replies View Related

Android :: Finish Activity Doesn't Work

Nov 5, 2009

In main Activity, I called start Activity For Result(intentB, 100) to start a new activity B, then in B, I called startActivity(intentC) to start another activity C. Lastly I wanted to call finish Activity(100) in C to close activity B, but seemed it was not successfully destroyed(I can use BACK key to see it's still there.)

View 6 Replies View Related

Android :: Finish Activity When Home Pressed?

Mar 25, 2010

I saw another thread related to this question, but did not find the answer that was useful to me. Is it possible when the user presses the Home button to be able to finish() my activity somewhere? I saw that people were having problems with using onStop(). Has anyone found a resolution to see if this is always called on Home being pressed?

View 5 Replies View Related

Android :: Finish Child Activity From Another In Droid?

Sep 14, 2010

I have a parent activity (as ACTIVITY GROUP) and some child activity of this parent activity (as ACTIVITY).
I am just calling child1 now i want to move from child1 to child2 and just want to finish() child1.
But when i am calling finish() it is also finishing the parent activity.

View 1 Replies View Related

Android :: Does Pressing Back Always Cause Activity To Finish()?

May 10, 2010

I've heard that pressing the back button will essentially cause the current Activity to finish(). Is this always the case? Seems like it would be with the way it pops the Activity off the stack.

The one situation I'm not so sure about is when the root Activity in a Task has back pressed. I'm currently experiencing a very weird effect, described as follows:

On loading my application, the first Activity is for initialization, and once it finishes, it calls my main Activity (a TabActivity). This first init activity has android:noHistory="true" set in the Manifest so pressing Back from my main Activity won't go back to that. It goes to the Launcher. When I click on my App in the Launcher a second time, the initialization activity loads again, and loads the main Activity when done. Almost immediately after, it loads a second instance of my main Activity. But ONLY after the Application has already been run once, and was exited by pressing BACK from the main Activity. It does it every subsequent time until I force quit the app or load a new version from the IDE.

Based on this, I am suspecting some kind of Activity instance is lying around and being reused, since it only happens on the second+ time I run the application (and exit with BACK -- using HOME just returns to the last state of the app, no big deal).

View 4 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 :: Calling Finish() After Starting A New Activity

Apr 26, 2010

The first Activity that loads in my application is an initialization activity, and once complete it loads a new Activity. I want to ensure if the user presses 'Back' they go straight to the Launcher, and not the initialization screen. Side note, is this even the best approach, or would this be better done with some kind of Intent Flag?

Is it correct to call finish() after calling startActivity() on the new activity?

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

I'm still taking in the whole 'Message Queue' method of doing things in Android, and my assumption is that calling startActivity() and then finish() from my first Activity's onCreate() will log each respective message in the message queue, but finish execution of onCreate() before moving on to starting the next Activity and finishing my first one. Is this a correct understanding?

View 1 Replies View Related

Android :: Why Restarting Activity When Call Finish()

Sep 10, 2010

I have an activity that after some user interaction calls finish() on itself. From time to time it gets into a loop where when it calls finish() it finishes but immediately restarts again. Any idea why android tries to restart my activity?

View 3 Replies View Related

Android :: Finish An Activity Not Started From Service

Jun 17, 2010

I've a service which listens to user request for ending one activity and starting another activity. For Ex: Say there are activities1,2 ,& 3. Now if there is already activity1 started by someother activity then based on the user request i need to stop activity1 and start activity2 or activity3. If the acitivity1 is started by my service then i can do finishactivity(requestcode) and shall receive a call to onActivityResult() then i can start next activity 2 or 3. But can i stop the activity1 which is started by some other activity from a service?

View 2 Replies View Related

Android : Activity Finish - X System Exit

Jan 21, 2010

I've been using System.exit to quit the application. Is Activity.finish a better approach? What would be the differences?

View 6 Replies View Related

Android : How Activity.finish() / StartActivityForResult() Collaborate With Each Other

Nov 12, 2010

I got a question about Activity.finish(). In my Android code, there are 4 activities(A,B,C,D). The starting activity A calls startActivityForResult(intent, reqCode) to start activity B. B starts C, and then finish(), not waiting for result. C does exactly the same as B, starts D and then finish(). D will return some result, by setResult(resultCode).

When my code runs and activity D returns some result, A will catch a RESULT_CANCELED on onActivityResult(), even if RESULT_OK is returned in D. I guess the RESULT_CANCELED is from activity B, which has been terminated before D returns a result, rather than from D.

But, my question is, why activity A catch RESULT_CANCELED after D returns some result, rather than immediately after B is terminated? And, what should I do to make A catch results from D? Do I have to keep B and C alive, to pass results from D to A?

View 2 Replies View Related

Android :: 1.5 And 1.6 After Calling Finish Activity And Home Button

Jan 12, 2010

I open splash screen at the end i call finish() then i moved to browse page. At the browse page when i click on home button it hide the application.(b/c of Android's Multi tasking feature) When i go to Android's desktop launch application again it starts from splash screen. Android Platform 1.6

I open splash screen at the end i call finish() then i moved to browse page. At the browse page when i click on home button it hide the application.(b/c of Android's Multi tasking feature) When i go to Android's desktop launch application again it always starts from browse screen instead of splash screen why is that..............

View 1 Replies View Related

Android :: How To Finish Series Of Open Sub-activities From One Activity

Apr 8, 2010

I am trying to make an exit button for my application. Anyhow I am able to track all the instance of activity in my application and then finish them all. But still some activity remain alive in some cases. Dont know how. Is there any method to kill a particular application in android. Or any other way can I exit from my application.

View 1 Replies View Related

Android :: Activity.finish() With AsyncTask Still Running In Background?

Apr 28, 2010

What happens on Activity.finish() with an AsyncTask still running in background?

Does it just pop the Activity off the Activity Stack, but wait to destroy the Activity object until the AsyncTask fully completes (since the AsyncTask is an inner class of my Activity)?

Also, would it act any differently if the AsyncTask were a public, non-inner class that held no references to the instance of the Activity?

View 1 Replies View Related

Android :: OnPause() Not Being Called For SingleTask Finish()'d Activity?

Feb 17, 2010

I'm not sure why onPause() is not called in the following scenario.

Here's my activity:

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

View 3 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 : How To Finish Old Activity / Start A New One / Vice Versa?

Nov 15, 2010

I know, that I get the same result with both code snippets

View 2 Replies View Related

Android :: How To Override The Back Button So It Doesn't Finish() My Activity

Jun 29, 2010

I currently have an Activity that when it gets displayed a Notification will also get displayed in the Notification bar.

This is so that when the User presses home and the Activity gets pushed to the background they can get back to the Activity via the Notification.

The problem arises when a User presses the back button, my Activity gets destroyed but the Notification remains as I want the user to be able to press back but still be able to get to the Activity via the Notification. But when a USER tries this I get Null Pointers as its trying to start a new activity rather than bringing back the old one.

So essentially I want the Back button to act the exact same as the Home button and here is how I have tried so far:

CODE:.........

However the above code still seems to allow my Activity to be destroyed, How can I stop my Activity from being destroyed when the back button is pressed?

View 4 Replies View Related

Android :: Return To Previous Activity Without Calling Finish() / Save This Information?

Oct 26, 2009

I have an android application with a LOT of activities, think of something like a book where every page is a new activity. The user can make changes in each activity, for example highlight certain texts with different colored markers etc. and it's crucial that I'll remember this information as long as the application stays alive (and I don't want/need to remember any of this when it's not). As I understand the best mechanism for storing this kind of information is via onSaveInstanceState(Bundle outState) and onCreate(Bundle)/onRestoreInstanceState(Bundle) rather than lets say, the Preferences mechanism. My only problem is that the user can navigate backwards to previous pages (Activities) and the only way i know of achieving this is by calling finish() which of course kills the current activity without calling onSaveInstanceState(Bundle outState) and even if it did call it, the next time I would launch an activity representing that page it would be an entirely new instance. So my question is: Is there a way to go back to the previous activity without calling finish()? or, is there a better way to save this information? maybe through static variables?

View 1 Replies View Related







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