Android :: How To Get Calling Activity Instance From Called Activity?

Jul 9, 2010

I have a Contact Activity which is derived from ListActivity, which displays list of contacts, and on click of item, a new Activity Message Activity derived from ListActivity is initialized.Now I know, I can pack some information in Bundle and pass it before creating activity, but is there a way I can get instance of "ContactActivity" in onCreate method of "MessageActivity"?

Android :: How to get calling Activity instance from called Activity?


Android :: Retain Only One Copy Of An Activity On Stack When Called From Non Activity

Jul 26, 2010

How can I make sure I only retain one copy of an activity on the stack when called from non-activity? When called from an activity I can just add the FLAG_ACTIVITY_REORDER_TO_FRONT flag to the Intent, but how can I do this from e.g. a widget or a notification?

View 1 Replies View Related

Android :: Handle Existing Instance Root Activity Launching Root Activity From Intent Filter

Apr 3, 2010

I'm having difficulties handling multiple instances of my root (main) activity for my application. My app in question has an intent filter in place to launch my application when opening an email attatchment from the "Email" app. My problem is if I launch my application first through the the android applications screen and then launch my application via opening the Email attachment it creates two instances of my root activity. steps: Launch root activity A, press home Open email attachment, intent filter triggers launches root activity A Is it possible when opening the Email attachment that when the OS tries to launch my application it detects there is already an instance of it running and use that or remove/clear that instance?

View 1 Replies View Related

Android :: Get Instance Of The Activity?

Jul 9, 2010

Is there a way to get an instance of the activity that has called the currently running activity from the intent object that has been passed to it? eg. if A has called B, I would like to retrieve A's instance from the intent in B's onCreate method. As Activity is not Serializable i am not able to pass the instance in the extras bundle.

View 1 Replies View Related

Android :: Recover An Instance Of An Activity

May 9, 2010

I have a bunch of tab activities (which I implemented myself, didn't want to use the tabviews with activities inside them), so It's basically 5 activities calling each other every time the user clicks on the tabs displayed as a row of LinearLayouts at the bottom of the screen.

The thing is that the way I do it now, everytime the user jumps from one activity to another, a new activity is created and launched. Of course, I can see I'm wasting resources this way. So what I would like to do is to create every activity only once; and then if the user wants to go back to the previous (or any one that was already created and is probably paused) just check on some kind of list or array to see if the activity can be recovered and only in the case it can't; to lauch a new one.

My question is, how can I check this? should I save the intents? and how to recover the activities afterwards? I'm kind of new with java.

View 2 Replies View Related

Android :: Get Instance Of The Launched Activity

Jul 19, 2010

Is there any way to get the instance of a launched activity(or any view in that activity )of a application in another application.

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 :: Push New Instance Of Main Activity?

Sep 2, 2010

Is it possible to create/push-onto-stack a new Activity of the same main Activity in an Android application with an argument passed to the Activities constructor? Specifically from a Dialog object...

View 1 Replies View Related

Android :: PendingIntent Always Creates New Activity Instance?

May 21, 2010

My app consists of an Activity and a service that runs in the background. The service periodically checks a website for an alarm condition. When the service detects the alarm, it should put a user notification into the status bar. If the user clicks the notification, it should display the app's activity. If the activity is already running, that activity should become visible. If the activity is not currently running, it should be created.

However the notification created by my service *always* creates a new instance of the activity, whether the activity is currently running or not. How do I get the desirable behavior?

Here is my service pseudo-code:

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

View 3 Replies View Related

Android :: Correctly Manage Activity Stack In This Instance?

May 28, 2009

I'm working to finish a small application, but I'm having problems seeing what combination of activity attributes and intent flags I need to achieve my intended application design. Trying my best not to describe the app in minute detail, here's the basic operation (I've supplied screenshots in the hope it makes sense easily): Users have a garden which contains flowers (GardenActivity).

http://www.tomgibara.com/images/daisy/garden/hut_screen.jpg

They can tap on a garden to see details of flowers (FlowerActivity)

http://www.tomgibara.com/images/daisy/garden/flower_screen.jpg

When flowers are fully grown a notification provided, tapping on the notification displays the garden containing the flower.

http://www.tomgibara.com/images/daisy/garden/notify_screen.jpg

Users can also use the GardenActivity as a picker to choose flowers to "exhibit" (ConfigureActivity)

http://www.tomgibara.com/images/daisy/garden/planting_screen.jpg

I want the app to operate so that if the user already has a GardenActivity somewhere in the stack (whether it's at the top, or underneath a FlowerActivity) the notification will alert the user by bringing that activity to the front (clearing any FlowerActivity that may be above it). I've tried using the FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TOP combination (without changing any activity launch modes) on the notification's pending intent, but it still launches a new GardenActivity, even if one is already available.

I've also tried using android:launchMode="singleTask" on GardenActivity. The notifications then seem to work correctly, but it prevents GardenActivity from returning any result back to ConfigureActivity.

View 3 Replies View Related

Android :: How To Tell A Thread From A Previous Instance Of Your Activity Has Finished

Oct 31, 2010

I'm writing a bitmap editor and I'm trying to write an autosave feature. When onPause is called, I write the application state to an autosave file. As this takes between 0.1s and 1.5s, I've been advised this IO operation be performed in a background thread.

In the onCreate method of my activity, I check to see if the autosave file exists and, if it does, I open it.

Are there any scenarios I have to consider where the user can somehow leave the activity, the autosave thread starts and the user can return to the activity before the thread has finished? If so, how can I detect this and wait for the thread to finish before I check the state of the autosave file?

I was going to make it that, when the user backs out of my activity, they're asked to wait a second while the data is saved. This seems OK, but I can't do this when my activity is interrupted by something like a phone call.

Also, I'm a bit confused about how multiple versions of the same activity can be started as this makes dealing with autosaving more complex. Is there a way to make sure only one instance of my activity is allowed to run at a time?

View 2 Replies View Related

Android :: Prevent New Activity Instance After Clicking On Notification

Jun 24, 2010

Application (non-wanted) behavior - application is started, some text is put into text-box and notification is created through button action. user "clicks" the home button, application is "minimized", notification is available in bar user selects the notification and the application is "maximized"

BUT - instead of the original instance, new instance is started (e.g. in the newest instance is missing the original text; when the latest instance is closed there is still the original instance with original text ) .

The code of the notification method

CODE:.....

I have also in the manifest xml file following tag android:launchMode="singleTask"

But it is still the same...The main problem is double/triple initialization of the application, i know that there are other means to preserve the values in resumed applications. Also it is needed that the applications stays running in background as the main functionality is the streaming of internet radio.

What is missing in the code ? What kind of information from my side is missing for to troubleshoot the issue ?

View 3 Replies View Related

Android :: Saving Cursor State With Activity Instance?

Apr 27, 2010

I've got an android app that pulls a random 20 questions (rows) as a cursor from a SQLite DB and loops through all the questions to ask the user all 20 questions.

Is there some way to save the cursor's state/location when the activity is paused or stopped so that when the activity resumes the cursor is restored and in the same position as it was when the activity was paused/stopped?

View 1 Replies View Related

Android :: AllowTaskReparenting - True Will There Be A Single Instance Of The Activity

Oct 4, 2009

Before asking my doubt, let me clarify my understanding of allowTaskReparenting...

Suppose there exists a Task (say Task 1) and this task has an activity (say Activity 1) which wants to call my Activity (say Activity 2). Let my activity (activity 2) set the attribute allowTaskReparenting to true and let my activity have a specific taskAffinity(affinity1). When Activity1 calls my activity (activity2), my activity becomes part of the task1. But suppose another task (task2) is already present/created with the same taskAffinity as mine (affinity1) and an activity in that task (say activity3) tries to start my activity, my activity gets re- parented to task2.

Not sure if i was clear enough. If i were to rephrase my words...

If my activity has allowTaskReparenting set to true and an instance of my activity is already present in task1. If task2 with the same task affinity as my activity tries to start my activity, the EXISTING activity gets re-parented from task1 to task2.

My quesions:

(1) Is my understanding correct ?

(2) If I am correct then a single instance of my activity gets shifted from task1 to task2. So 2 activity objects of my activity are NOT created.

View 5 Replies View Related

Android :: New Activity Instance Created For Every Intent-filter?

Feb 6, 2010

I'm using an intent-filter on URLs for my activity:

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

the launchMode attribute is set to "singleTop", but it looks like a new activity is created every time I click a matching url. I thought that if the activity is already alive somewhere, it would simply be brought to the front of my activity stack?

I tried this on the emulator/device, same behavior, a new activity instance is always created.

View 2 Replies View Related

Android : Single Instance Theme Of An Activity In Phone

Sep 7, 2010

I have two activities. A and B. A starts B. Both are running in the screen and both are visible. Say now B is visible.

On a special key press, I want to bring the A to the front and make it active. The problem I am facing is when the special key is pressed, another instance of A is launched and the new instance is brought to the front.

But I want the original A to come to the front. I want to make this change in the framework layer rather than application specific by using the singleInstance theme in the launchMode in AndroidManifest file.

Please help me in this regard as this is really urgent for me. Any inputs will be really valuable for me.

View 1 Replies View Related

Android : Inside TabActivity / How To Get Instance Of Current Tab Activity?

Apr 23, 2010

I have attached a menu to my TabActivity, and when a menu item is selected, I would like to do something different based on which view is being currently displayed in the TabHost.

int getCurrentTab() returns me the id of the current tab... but from that int how can I get the instance of the activity running?

I also tried getCurrentView(), getCurrentTabView(), but these return things I can't seem to cast to the class of the current activity.

View 3 Replies View Related

Showing Activity Without Recreating Instance?

Oct 4, 2011

1) I dont want to re-create activity once it is created in order to show. How can I do this ? like showing activity from back stack whenver thers a call for it. (It might appear at any index in back stack.)

View 1 Replies View Related

Android :: Previous Set Instance Variables Null When Activity Resumed

Apr 20, 2010

I am using an Application object to store app-wide instance data--data that I need to remain in existence for the entire lifetime of the app, so the Application class seems like the proper place to put it. I have just finished reading this thread http://groups.google.com/group/android-developers/browse_thread/threa... that goes into pretty good detail and receives confirmation from Googler hackbod as to how the Application class performs--and from that info it seems this strange behavior I am receiving should not be happening...

Basically, every once in a while when I resume my app in any of its Activities (it is still running in memory so onCreate is not called) I get NullPointerExceptions because instance variables in my Application class are returning null when I request them from my Activity (via a getter method in my custom Application class). It seems as if sometimes Android saves the states of my Activities but deletes all my instance variable data... This can't be an Android problem--there must be something wrong with my code.

Has anyone else ever ran into an issue of this kind? Any ideas as to what may be causing this? I'm not going to post my code here as that won't help anyone, but hopefully someone can point me in some helpful directions.

View 11 Replies View Related

Android :: Acitivity Managing - Always Starts New Instance Of Activity And Fetch Data From DB

Nov 17, 2010

I have been in problem of the Activity life-cycle. All though i read lots of docs on it put on getting clear picture on it. I have Activity A. In that activity I have menu options. If we click any option it opens the respective activity like if i click on 2nd button it opens Activity B Now again Activity B has same options into it. When user clicks on 1st button then i need to go back to activity A. So using this. Intent intent = new Intent().setClass(context, Articles.class); startActivity(intent); So always it starts new instance of activity and fetch data from DB. I want something like Activity A can be resumed back as it was.

View 6 Replies View Related

Android :: How Do I Know If Activity.onStop Is Being Called?

Dec 3, 2009

I need be able to tell if Activity.onStop() was called because my application is moving to a new activity, or if it was closed because the user pressed the "Home" key or hit the back button from the bottom of the activity stack.The reason is because I need to know when it is appropriate to shut off music that is playing in my application (A game). There is nothing more annoying than hitting home and having something playing music in the background.However, Activity.OnStop() is called for each activity change, and I don't want to suspend music when moving between multiple activities in my app. I just can't find a way to differentiate between going home and going to a internal activity.Am I perhaps hooking into the wrong events?

View 3 Replies View Related

Android :: Does OnActivityResult Get Called When An Activity Is Recreated

Sep 30, 2009

I have a flow A->B->C->D where A desires some information that is obtained by D. B, C, and D propagate the data back through the flow using setResult(RESULT_OK, data) and finish(). All intents in A, B, and C are started with startActivityForResult. However, if B is reclaimed by Android and forced to call onCreate again after C finishes onActivityResult in B is never called and the data never makes it back to A. Is there a way I can be sure that onActivityResult will be called?

View 5 Replies View Related

Android :: Same Activity Called Twice - Multiple AsyncTasks?

May 8, 2010

I have three simultaneous instances of an AsyncTask for download three files. When two particular ones finish, at the end of onPostExecute() I check a flag set by each, and if both are true, I call startActivity() for the next Activity.

I am currently seeing the activity called twice, or something that resembles this type of behavior. Since the screen does that 'swipe left' kind of transition to the next activity, it sometimes does it twice (and when I hit back, it goes back to the same activity). It's obvious two versions of the activity that SHOULD only get called once are being put on the Activity stack.

Could this be from both onPostExecute()s executing simultaneously and both checking the flags each other set at the exact same time? This seems extremely unlikely since two processes would have to be running line-by-line in parallel...

A lot removed from this question since I was way off in what I thought was wrong. Nonetheless I found the answer here quite useful, so I have edited the question to reflect the useful parts.

View 1 Replies View Related

Android :: Image Capture Intent / Activity Not Get Called

Jun 26, 2009

I start an IMAGE_CAPTURE Intent like this, and my activity's onActivityResult() get called: Intent i = new Intent (android.provider.MediaStore.ACTION_IMAGE_CAPTURE, null); i.putExtra("return-data", true);
startActivityForResult(i, PICK_ICON_FROM_CAMERA_ID);
But, if I start my Intent like this, the Capture Image Intent did get called, but my activity's onActivityResult() never get called:
Intent i = new Intent (android.provider.MediaStore.ACTION_IMAGE_CAPTURE, null); i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse("file:/" + "MyTestFile")); i.putExtra("outputFormat", Bitmap.CompressFormat.PNG.name());
startActivityForResult(i, PICK_ICON_FROM_CAMERA_ID);

View 3 Replies View Related

Android :: Activity Lifecycle On Nexus One - OnStop Not Called

Mar 4, 2010

I have a problem with the activity lifecycle specifically on Nexus One (2.1 running on emulator works fine). If I just create a simple empty Activity with no special launchModes that logs the calls on the onStart and onStop methods, this is what I see: - launch app: onStart called; - home button: onStop NOT called; - launch app: onStart NOT called; - home button: onStop NOT called: and so on. Sometimes if I press the back button then the onStop is not called, but the when i launch the activity again the onStart is called and right after the onStop is called. Similar results with different launchModes. What is going on? Can anyone confirm this?
i found an android issue for the problem here: http://code.google.com/p/android/issues/detail?id=6094 and a similar thread here http://groups.google.com/group/android-developers/browse_thread/threa.

View 24 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 : Webview - OnCreate Always Get Called When Activity Comes To Foreground

Mar 29, 2009

I launch my TestWebView activity. After my web page is loaded, I put the app in the background by pressing the Home key. Then I bring the TestWebActivity back to the foreground. Unexpectedly, TestWebView's onCreate() is called when I bring the activity to the foreground. But onDestroy is never called. This same thing happens every time I tested. It appears the old TestWebView was not completely killed so there are possibly duplicate web clients running.

My code: .....

View 7 Replies View Related

Android :: Calling StartActivity From Outside Of An Activity

Dec 7, 2009

I have a TabActivity subclass that attempts to start a new activity via a menu item selection in onOptionsItemSelected.I am receiving the following exception which eludes me at the moment.I'm not sure why it thinks I am *not* in an activity!

View 2 Replies View Related

Android :: Calling Activity From Service

Nov 19, 2010

i am writing an app in which i need a background service to call an activity and show some result.

View 4 Replies View Related

Android : Error While Calling An Activity From Another / How To Fix

Apr 4, 2010

me and my partners are working on developing a pwa client for android Am getting an error while calling an activity from another activity.the error is as follows...

View 3 Replies View Related







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