Android : Current Activity Reference From Within Service
Oct 30, 2010
So say there's an app running (any app). I'd like to be able to get it's Activity from within a Service that will be triggered to run from a android.intent.action.SEARCH_LONG_PRESS.
Is this possible?
View 1 Replies
Apr 9, 2009
Is it possible to get the currently running activity through Service..?
i.e. I have a service started by an Activity A, and now I want to stop the service by another activty say Activity B.
Since Activity B doesnt know about the service, i want to capture the events in OnKeyDown() of the Activity B in my service...
Is this possible.. How can i get the Activity B's object..?
View 6 Replies
View Related
Oct 6, 2010
Is there a native android way to get a reference to the currently running Activity from a service?
I have a service running on the background, and I would like to update my current Activity when an event occurs (in the service). Is there a easy way to do that (like the one I suggested above)?
View 2 Replies
View Related
Aug 4, 2009
I have been looking for this for a while but I can't find any way of doing it. A contrived example would be a service that simply displays the name of the current running activity as an Ongoing Notification. For instance, when the user is reading a particular email, the name of the activity (hopefully the email title!) would appear in the notifications window and when the user switches to read a text message, the notification would change to show the name of the new activity. Is there a way to do this in Android?
View 2 Replies
View Related
Jul 21, 2010
When you do a Thread.currentThread().getId(), is the resulting thread id scoped per process or scoped to the current Activity/Service?
View 1 Replies
View Related
Jun 24, 2009
I have a service running in the background.I have a background thread that gets a reference to the service from the application's main activity. But when the background thread calls a method in the service to display a toast, I get the "Looper not initialized exception".Why,if I have a valid, bound reference to a Service, does this still happen?
View 4 Replies
View Related
May 13, 2010
The default behavior of an activity when BACK softkey is pressed is, GO BACK TO PREVIOUS ACTIVITY. If some the same activity is waiting for some response from server or some data updation is going on and then press BACK, I want to wait on the same screen till the current task is completely processed and then move out to the previous activity.
You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscribe@googlegroups.com For more options
View 12 Replies
View Related
Jul 28, 2010
I have a local Service running together with my application. I also have a class derrived from Application class.
When the local service is created it gets and uses the Application instance using getApplication.
Can the app itself be terminated while my service is still running and what happens if so? Would getApplication return null?
View 1 Replies
View Related
Oct 28, 2009
I have a custom view that needs a reference to the activity that created it.Dianne Hackborn said in another thread: >Give your view a reference to the activity (or a Java interface it implements) and call back through that. >Much much MUCH more efficient than sending a broadcast. >See all of the standard view and view subclass callbacks for examples.
View 9 Replies
View Related
Jun 17, 2010
Would it be there noticeable speed improvement if I would create local references to needed view elements (e.g. EditText or Button) in my activity (in onCreate()) and use them for accessing needed elements or it does not much matter if I always use findViewById() when I need to access some particular element?
View 2 Replies
View Related
Aug 27, 2010
My app is comprised of a set of reusable Activities that other apps can reuse. For various reasons, I would like my Activities to be launched in context of the invoking Activity's process, instead of always being launched in my Activity's process (default behavior on Android). How can I achieve this?
View 1 Replies
View Related
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
Nov 5, 2010
The default behavior from my observation is if current activity force closes Android tries to go to previous activity on stack How can I control this behavior? I want force close to close all activities
View 2 Replies
View Related
Jul 16, 2010
I used Toast to make notification, but it seems it will appear even its activity is not in the current screen and some other activity has been started.I want to check this situation, when the activity is not the current one, I'd not send the Toast notification. But how to do ?
View 1 Replies
View Related
Jul 20, 2010
I want to have a class "Utils", that will have several methods used all over my code. For example, I have a top bar with a textview and two ImageButtons that must display different texts and icons on different activities.I created the class Util, but it doesn't extend Activity. The problem is that if it doesn't, findViewById isn't there, can't find stuff etc.
View 1 Replies
View Related
Mar 9, 2009
I want to pass a class reference to an activity, and then the activity will construct the view according to the content of the class.
How could I implement this function?
View 3 Replies
View Related
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
Jul 24, 2010
I have an AsyncTask that scans the file system and publishes progress through Notifications. To do this I need a reference to the current Activity in the AsyncTask.
I also don't want to kill the task when the activity is destroyed. How do I avoid leaking the activity and everything it references on each configuration change?
One possibility is to remove the reference in OnPause() to be sure it is gone when the Activity is destroyed, but that would mean notifications stops coming as soon as you leave the activity which is no good.
Isn't there a recommended way of dealing with AsyncTasks in this way?
View 12 Replies
View Related
Oct 2, 2009
startActivity() displays the new Activity on top of the current one. But how to display it underneath instead? BTW, I'm starting an Activity from another application, if that makes a difference.
View 5 Replies
View Related
Jul 29, 2010
Is it possible to add an activity on top of the current activity.
For example lets say i click a button, and then it adds a second activity to the current activity. And the second activity only covers a small place at the bottom of my current activity.
View 3 Replies
View Related
Aug 2, 2010
Whenever the memory needs to be reclaimed, the process is being killed by Activity Manager Service in killPidsForProcess. I have a back button in my activity window on right corner of the title bar.
I want to kill the activity completely on clicking the close button. Can I reuse the same function and will it have any major effect? Please help me out in this.
View 3 Replies
View Related
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
Nov 24, 2010
I need to launch a service running in the background,that should record what's on the current screen for say about 10 sec.. i should able to save it in a file or on any storage device and later i should able to retrieve it also..
View 2 Replies
View Related
Sep 10, 2010
I need to made an activity (without layout) that on start check if a service is running. if it is true it starts Activity2, if it false it starts Activity1.
I tried with this code:
CODE:............
Enter code here
But when I check, in the onCreate method, if serviceConnect!=null I receive sometime a NullPointerExcption.
I tried also to insert the operation in the method onCreate in an Async Task:
CODE:............
View 2 Replies
View Related
Aug 11, 2010
I have Serviceļ¼Sometimes current run Activity work in background I don't want to know. I want to know current work interface Activity name?
View 3 Replies
View Related
Jan 30, 2010
I wish to have one application that runs in the background, which knows when any of the built-in applications (messaging, contacts, etc) is running. So my questions are: How I should run my application in the background. How my background application can know what the application currently running in the foreground is.
View 4 Replies
View Related
Apr 8, 2014
I have a Service that I am running in the background every minute. It's an IntentService and I start it like this:
Code:
Intent i = new Intent(context, GPSTracker.class);
PendingIntent pi = PendingIntent.getService(context, 0, i, 0);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
[code]...
That works, my Service is being run every minute (give or take a couple seconds for some reason) whether the app is up, closed, the phone is sleeping, whatever. how I should be getting the current location from this Service. I'm attempting to use LocationListener and a mix of getLastKnownLocation and hoping onLocationChanged will be called.
I think my problem is, onLocationChanged is barely getting called. Everytime the service runs and I do getLastKnownLocation I send a message to my database to check, I send a different message everytime onLocationChanged is called. I went to the store and back and getLastKnownLocation was called a few times, but onLocationChanged was only called once and it was incorrect. getLastKnownLocation always seems to be incorrect to.
Code:
protected void onHandleIntent(Intent intent) {
Log.i(TAG, "In onHandleIntent!");
Location currentLocation = getLocation(this);
if(currentLocation == null) {
saveLocation(-8.0, -8.0, "nothing", "nothing", "nothing");
[code]...
View 1 Replies
View Related
Oct 19, 2010
How can I know what Activity has started the current Activity? Is there any specific method like, i.e. getIntent().getCallerActivity() or the only way is saving some information within the Intent using putExtra()?
View 1 Replies
View Related
May 17, 2010
I am trying to make a task switcher and i succed in it. My only problem is that when I launch activities, they are relaunched as they were new activities ( for instance, I am writing an email, i press home and go into my activity,launch email, and then the app launch the email bout goes back at the inbox and the email is lost) So that's not true multitasking.
View 2 Replies
View Related
Jun 11, 2009
Is there a function that allows me to get the top most view (the root)?
View 2 Replies
View Related