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.

Android :: get instance of the launched activity


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

View 1 Replies View Related

Android :: Recieveing A Notification When An Activity Is Launched

Jun 30, 2010

Is there a way of recieving a notification of some sort when a activity is launched. I'd like to monitor which applications are used and how often. Is is possible to register for some broadcast telling me when an application is launched, installed, unistalled etc? I believe I found a discussion or solution to this yesterday when I was looking for something else, but I'm not able to find it today.

View 3 Replies View Related

Android :: BroadcastReceiver To Listen For Activity Being Launched

Jun 22, 2010

I am wondering whether is possible to use a BroadcastReceiver to listen for an Activity being launched. I have no control of the Activity I need to know about as it is from the Android platform.

View 3 Replies View Related

Android :: Determine If A Specific Activity In An Application Can Be Launched

Jun 9, 2010

Applications can have any number of launchable activities. I know how to get the list of these activities via PackageManager.

Is there a way to determine which activities can be launched via startActivity?

For example, the Documents To Go app has different activities that will start Word, Excel, Powerpoint, PDF, etc... I am able to launch all o these just fine.

However, it also contains some activities that I am not able to launch with startActivity... If I attempt to do this I get a SecurityException.

I want to be able to determine which activities I can safely launch and which I cannot so I only present the user with a list of activities that I can safely launch from within my application...

View 1 Replies View Related

Android :: Detect When Another Activity Is Launched Or Loses Focus

Dec 3, 2009

Like the title says, I need to detect when my app loses focus because another app is launched (Phone call comes in, or user hits Home etc.).
Overriding Activity.OnStop does not work because that is called even when switching activities within my app.

View 3 Replies View Related

Android :: Task Activity Stack Always Reset When Launched From Home

Mar 24, 2009

I am just starting on an Android app and I am puzzled about why my Task activity stack is being reset any time the application is launched from the Home screen. I used the ADT tools to create the application in Eclipse. The main activity is ".UserLaunch" and it starts the activity ".About" when the user presses a button. If the user then presses HOME and then relaunches the app, .UserLaunch is displayed and is the only thing on the stack.

.UserLaunch has the launchMode singleTask. .About is standard. According to the documentation at http://developer.android.com/guide/topics/fundamentals.html#lmodes: "However, a "singleTask" activity may or may not have other activities above it in the stack. If it does, it is not in position to handle the intent, and the intent is dropped. (Even though the intent is dropped, its arrival would have caused the task to come to the foreground, where it would remain.) "The Task stack should be brought to the foreground and .About should still be displayed. I added Logging to all of the lifecycle events (edited to remove timestamps and shorten DEBUG/ and INFO/ to D/ and I/) and you can see that when HOME is pressed, .About cycles through onPause and onStop (as expected). Then when the app is again launched, .About is destroyed and .UserLaunch is restarted D/UserLaunch:(670): onCreate() D/UserLaunch:(670): onStart() D/UserLaunch:(670): onResume() I/ActivityManager(52): Displayed activity com.cequint.cityid/.UserLaunch: 4910 ms I/ActivityManager(52): Starting activity: Intent { comp= {com.cequint.cityid/com.cequint.cityid.About} } D/UserLaunch:(670): onPause() D/About(670): onCreate() D/About(670): onStart() D/About(670): onResume() I/ActivityManager(52): Displayed activity com.cequint.cityid/.About: 1031 ms D/UserLaunch:(670): onStop() I/ActivityManager(52): Starting activity: Intent { action=android.intent.action.MAIN categories= {android.intent.category.HOME} flags=0x10200000 comp= {com.android.launcher/com.android.launcher.Launcher} } D/About(670): onPause() D/About(670): onStop() D/dalvikvm(670): GC freed 413 objects / 34128 bytes in 72ms I/ActivityManager(52): Starting activity: Intent { action=android.intent.action.MAIN categories= {android.intent.category.LAUNCHER} flags=0x10200000 comp= {com.cequint.cityid/com.cequint.cityid.UserLaunch} } D/About(670): onDestroy() D/UserLaunch:(670): onRestart() D/UserLaunch:(670): onStart() D/UserLaunch:(670): onResume() Here is the relevant section of the Manifest: <application android:icon="@drawable/icon" android:label="@string/ app_name"> <activity android:name=".UserLaunch" android:label="@string/app_name" android:launchMode="singleTask" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".About" android:launchMode="standard"> </activity> </application> Anyone have any ideas why this is always resetting the Activity Stack?

View 11 Replies View Related

Android :: Droid Instrumentaion : Go Back To A Previously Launched Activity?

Feb 19, 2010

Is there anyway to go back to a previously launched Activity while running an Instrumentation test? Currently, when I use sendKeyDownUpSync( KeyEvent.KEYCODE_BACK);, this forces my test to exit, rather than go back to the previous Activity.

View 2 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

Recovery State Of First Activity Launched?

Jan 15, 2010

I have an application that launch a thread when a ToggleButton is pressed, but if I press the home button, a new activity is started (I can return to the first activity if I press the back button), but I want to recovery the first activity launched state, which have the reference of the initial thread.

This is my code:

org.test.test.java:

////////////////////////////////////////
package org.test;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.ToggleButton;

[code]....

View 5 Replies View Related

General :: App That Run Shortcut (activity) When Launched

Jul 21, 2012

Various parts of the Android system or Android apps are designed to launch a program, but aren't capable of launching an application shortcut. For example, they're willing to run a timer application, but they aren't willing to run its "start timer now" shortcut. One example is the samsung ICS lock screen, which is neat in other respects but suffers from this really lame limitation.

Is there an app that can be configured to run another app's shortcut? For example, I could configure the lock screen to launch "Fast Shortcut Helper", and fast shortcut helper will have already been configured to run the "start timer now" shortcut.

View 2 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 : Multiple Activity Instances Launched By Same Intent. Bring One Uniquely To Foreground?

Nov 12, 2010

I'm struggling with my app that launches multiple instances of the same Activity using the same intent. My main activity is of class type A and it does a startActivity() of two children that are of the same class type B. So we have B1 and B2 launched. If B1 and B2 are both paused (by pushing back button and making sure finish() is not invoked on them so they are truly paused), how can A uniquely bring either B1 or B2 to the foreground again? I do want to launch a new B activity. I want to uniquely bring B1 or B2 to the foreground.

so both B1 and B2 were created like this... Intent intent = new Intent(context, B.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);

Now I want A to bring B1 (or B2) to the foreground/front so I use the below code, but how do I distinguish B1 or B2 when starting the activity? This only brings the last instance of B that was on top to the foreground.

Intent intent = new Intent(context, B.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent);

I've tried keeping around references to B1 and B2 and doing something like this, but this also only goes to the last instance of activity class B that was on top...

Intent intent = new Intent(B1context, B.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); B1context.startActivity(intent);

I even tried this, but it still doesnt get me my unique B1 or B2... Intent intent = B1.getIntent(); // i.e. the original intent that started me startActivity(intent); // still only brings to front the last B that was on top.

View 3 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 :: 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

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

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 :: 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 :: Launch The Same Activity From Widget With Different Extras - Prevent Same Instance Show Up After Returned From HOME Button?

Nov 5, 2010

I have a widget that contains 4 buttons to show 4 stock prices, each of them will launch into the same activity Quote.class to show stock details. In onUpdate(), it will set up the pendingIntent with extras with stock symbol. After I hit button A, it goes to Quote activity that shows stock A. Then I hit the BACK button to the homescreen, Quote activity calls onDestroy() and when I hit button B, stock B will show properly. However, when i hit HOME button after it shows stock A, the Quote activity only calls onStop without calling onDestroy(), then as i hit button B, it will call onStart() and it shows the same instance that shows stock A.

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

Originally I thought adding a flag in the Intent should solve this problem. But I have tried
i.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK or FLAG_ACTIVITY_NEW_TASK or FLAG_ACTIVITY_NO_HISTORY), none of them makes any difference.

So is there any ways to make it work? How can i remove the history stack from HOME button? How can I call onCreate in Quote activity and get new extras when i hit button B?

View 4 Replies View Related

Android :: Instance Variable Of Activity Not Being Set OnPostExecute Of AsyncTask - Return Data From AsyncTask

Jul 28, 2010

I'm trying to figure out the correct way to create an AsyncTask to retrieve some data from the internet and then to take that data and bundle it up in an Intent and pass it to a new activity(A list display). So in the first activity I just have an EditText and Button. In the event of an OnClick the task should be called and when it is finished the data should be bundled inside an Intent and passed to the next Activity. The problem is when I take the results from onPostExecute and set them to an instance variable of the main activity, that instance variable is still null when the task is complete. Here is the barebones version of the code:

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

When I debug the application I see onPostExecute does contain a valid PlacesList full of results, so why is the instance variable places set to null after the task is executed? I am going about "returning data" from an AsyncTask incorrectly?

View 1 Replies View Related







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