Android :: How Local Service Can Invoke A Sync Method On It's Main Activity?
May 2, 2010
I've configured local service under some app i wanna know how could i invoke methods on the activity, through the service in a synchronous way for example the service invoke a method inthe activity and waiting for for result(synchronous) from it.
View 2 Replies
Jun 1, 2010
I'm trying to think of a way on how to sync in between a local service and the main activity.
The local service has,
A thread with a socket connection that could receive data at any time.
A list/array with data.
At any time the socket could receive data and add it to the list.
The activity needs to display this data. So when the activity starts up it needs to attach or start the local service and fetch the list. It also needs to be notified if the list is updated.
I think I would need to sync my list somehow so the local service does not add a new entry to it while the activity fetches the list when connecting to the service.
View 2 Replies
View Related
Oct 15, 2010
Could some one please tell me how to invoke an activity from a service when the service receives some content from a server. the service keeps getting the data and the activity needs to update itself.
I am unable to find a good tutorial for broadcast intents stuff.
View 1 Replies
View Related
Oct 29, 2010
Can anybody tell me what method of an activity executes when an application closes?. Like I have a main activity and if I press back button on my phone. The Application closes so I want to know what method executes at that time.
View 1 Replies
View Related
Aug 8, 2010
I am using the following method in a new application I'm developing. There is a main activity, which instantiates different classes that extends RelativeLayout and I'm using setContentView to switch between the different modules of the application. I wonder if this is a good approach or necessarily I have to use different activities to the several screens the app haves.
View 1 Replies
View Related
Feb 22, 2009
Starting from the example ServiceStartArguments.java of the "API demos", the service "ServiceStartArguments" is creating a new Handler object (ServiceHandler) which does all the work in a separate thread. Once that work is completed, how can I tell other components that my work is finished, and also provide data (that resulted from the work) to them?
I tried something like startActivity(intent_transferred_via_msg) which does not work, I'll get an exception because I call it "outside of the service", which is technically true.
View 3 Replies
View Related
Sep 13, 2010
I'm trying to create a program with a service that runs every 10 seconds, puts the camera preview, taking a picture and then leaving the user to continue his work (closing down). Currently I have two problems:
1. After I'm taking the picture, the preview still there. There's no function like close() to return to the previous activity. How can I return to the previous activity?
2. I'm trying to run the above described activity from the run() function (from the timer class that execute the run() function every 10 seconds). When I do that, a runtime exception is raised. But when I start the above described activity from a button clicked (not from the timer) it works fine.
View 4 Replies
View Related
Aug 24, 2010
I have a service which collect data and send them to a certain URL and updating the main activity GUI, so which is better in the performance to use a long service with listeners to collect the data and threads in it to update the GUI and sends to the internet or to make another service responsible for updating the GUI and sending to the URL only while the first one just collects the data?
View 5 Replies
View Related
Nov 11, 2010
so the application I've written has a service (that tracks GPS data) with a single main activity that binds to it with bindService in it's onStart() method, and unbinds from the service in it's onStop() method using unbindService( ServiceConnection ). I also have an activity which is an options screen, that is launched by pressing a button on the main activity. On this options screen, I have a checkbox that says "Run in background", which, if set to true, means that when the user exits the application with eier the Home or Back buttons, the service will continue running, not turning the GPS off. I do this by calling this.startForeground onUnbind, and this.stopForeground onRebind, if the setting is set to true, and stopping and starting my location reader onUnbind and onRebind respectively if the setting is false. If the service is running in the background, it also displays a notification to ensure the user understands that the GPS is still running and draining their power. This notification is displayed and stopped by relying on the startForeground and stopForeground methods......
View 1 Replies
View Related
Oct 30, 2010
In my application, there is a service which has a running thread to capture data from remote server, and also this service is triggered by AlarmManager, for example let 1:00 am to start the service. After the service finish the task, it stop itself and the main activity need to update GUI. I don't know how to let the main activity know when the the service stopped, so that the main thread can update GUI.
View 3 Replies
View Related
Mar 30, 2009
How do you pass an intent from a service to a new activity launched from a main activity? There's a passextra( intent src ); but I don't think thats what I am looking for?
activity main > start service( intent wuteverserviceintent );
activity main > start activity( intent newactivityintent );
View 2 Replies
View Related
May 3, 2010
I have a widget that is supposed to start and stop a service (start it when it's not running, stop it when it is). This is working fine, however, each time the service is started, my app's main activity is also launched, which I don't want from the app's manifest, it works as I want it to (without launching the main-activity, just the service), but then I obviously don't have a main activity anymore.This is how I start the service (I would assume this is the normal way, and I can't see any reference to what might cause the MAIN intent to fire).
View 1 Replies
View Related
Nov 19, 2010
I wrote an android program that: has a main activity for UI, and it starts a service. The service timely callbacks the UI activity to update views. It works fine except: if the activity is closed (with BACK) and start again, the service will also be started again (The service plays audio file, so there are two overlapped sounds). I use bindService with BIND_AUTO_CREATE flag to start and connect to service. According to the document, it should create service only if it doesn't exist, but obviously it starts another instance when opened second time. All I want is when the activity is closed, the service goes on running, and when the activity opens again, it can reconnect to the service. Is that possible? Or I just misunderstand the usage of service?
View 1 Replies
View Related
Feb 16, 2010
I have the folowing method in a Service in my appplication: Code... Do I have to do an AIDL or is there a simpler way?
View 2 Replies
View Related
May 20, 2009
I came to this issue : I created a layout with only 1 ImageButton and it works as expected when loaded from Activity (using setContentView) : The button is changing background on touch down event (orange) But not changing when the same layout is loaded by the InputMethodService (but it react to onClickEvent if used ) Here is a minimal project and video if you need to reproduce : http://rzr.online.fr/tmp/rzr-test-android-imf-0.0.20090520.tar.gz
View 4 Replies
View Related
Jul 2, 2010
I am trying to call my service class's stopService() method from my activity. But I don't know how to access stopservice method from my activity class. I have the below code but its not working. This is HomeScreen class:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
enablecheck = (CheckBox)findViewById(R.id.enablecheck);
enablecheck.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if(enablecheck.isChecked()){
startService(new Intent(HomeScreen.this, AutoService.class));
} else {
stopService(new Intent(HomeScreen.this, AutoService.class));
} } });
}
This is Service Class:
public class AutoService extends Service {
private static final String TAG = "AutoService";
private Timer timer;
private TimerTask task;
@Override
public IBinder onBind(Intent intent) {
return null;
} @Override
public void onCreate() {
Toast.makeText(this, "Auto Service Created", Toast.LENGTH_LONG).show();
Log.d(TAG, "onCreate");
int delay = 5000; // delay for 5 sec.
int period = 5000; // repeat every sec.
timer = new Timer();
timer.scheduleAtFixedRate(task = new TimerTask(){
public void run() {
System.out.println("done");
} }, delay, period);
}
@Override
public boolean stopService(Intent name) {
// TODO Auto-generated method stub
timer.cancel();
task.cancel();
return super.stopService(name);
} }
View 3 Replies
View Related
Aug 6, 2010
I have an activity A which uses SharedPreferences to share data with a service S, which is called from within A.Now when I call the stopService() method from A, the onDestroy() method in S is not called immediately.I thought that all the activities and services under a single apk run in just one process. Why then does the jump to onDestroy() not take place immediately instead I can see the output from onDestroy() after the further code in the activity A is executed.
View 5 Replies
View Related
Nov 18, 2010
I'm confused why is my activity still lagging, I use remote service that has few methods and each has its own work like download stuff, process data, compare stuff, etc... It will run in background and update data at selected intervals and notify user of changes over notify system.
The reason why remote service, because I will eventually add a widget, and service needs to stay running even if android kills the activity, so I unbind it on each onPause().
But as far I understand that part doesn't cause my issue.
But back to my problem... so my is Activity still lagging when I run stuff in service and handler.post method.
here is the code...
Also I wanted to add progressDialog to be updated in updateLayer(...) through Activity is a listener to this service, but thats not working well. Whats the best way to update progressDialog? Ever listener, handler, intent, or what?
So how do I do this correctly?
View 2 Replies
View Related
Aug 23, 2010
I want to judge the call has been connected. So I want to invoke method called isAlive() in the hide abstract class Connection(com.android.internal.telephony)?
View 6 Replies
View Related
Sep 4, 2010
I use Microsoft Outlook 2007 as my MAIN email and calendaring software. I will be accessing my mail and calendar via Outlook on my office PC for the vast majority of time.
My main email accounts are currently configured as POP3 but are also configured to leave copies of messages on the server for 30 days, which allows me to check new messages via my ISPs webmail when out of the office.
I have considered changing to IMAP for my main email account but have purposely avoided it up to now as I have a huge number of mail folders and messages my Outlook pst file is currently 7.2GB. A lot of those are for archive reference and I dont need to see them on other devices BUT, as I understand it, IMAP does not let me only select certain folders to mirror and sync between different devices (it must sync all of them) so I feel it would be unwieldy to use IMAP on my account. (If anyone knows of a way to set IMAP to only include specific folders please let me know!).
I do have a Google Mail account already, but rarely use it its just there as a back-up account. I�ve NOT as yet imported my Outlook contacts or calendar into my Google account.
Now I know that I can use HTC Sync to sync up my Contacts and Calendar, but what I�ve read suggests that the phone works best when you sync it with your Google account. I COULD of course import my Outlook Contacts and Calendar into my Google account, and I COULD also use my Gmail account to check mail from my main POP3 accounts. However, Im unsure about going down that route as Im worried that might confuse things, cause conflicts, or cause double-work for me when I update my contacts or calendar from Outlook or from Google. Are there possible problems with going down that route?
Secondly, Im very intrigued to have read that Gmail is more efficient for the phone as Ive read it works as a push email service. That is, I dont need to check my mail by doing a send/receive from my phone either manually or automatically at set intervals, but that Gmail will just automatically PUSH new emails to my phone as soon as they arrive. Is that correct?
If it is correct it sounds good, but does that mean my phone must be or will be permanently connected to the net? As I don�t use my mobile that much Im on a Pay-As You-Go service so need to ensure my phone is ONLY connecting to a data connection when I need it to. Will I be able to work-around this?
I know HTC Sync doesn't transfer Outlook Notes or Tasks. Has anyone found, or can recommend, an app that will do that for me?
View 5 Replies
View Related
Aug 31, 2010
I am try to use reflection to invoke the "List Camera.Parameters.getSupportedFocusModes()" function with the following codes:
CODE:..............................
The log shows it does find the function, however, the result o is always null, why is that?
View 1 Replies
View Related
Apr 14, 2010
This question occured to me while programming a Android application, but it seems to be a general programming question more.
The situation is, I am extending (subclass-ing) an class from a library, and overriding a method. how do I know if I should invoke the method of super-class? and when? (in the beginning of the overridden method or in the end?)
For example, I am overriding the method "public boolean onCreateOptionsMenu(Menu menu)" from class "Activity" in Android platform. And I saw someone write "return super.onCreateOptionsMenu(menu)" in the end of the method, in an example. But how do I know it should be done this way? and it is correct or not? what's the difference if I begin my method with "super.onCreateOptionsMenu(menu)"?
View 6 Replies
View Related
Mar 19, 2010
How to invoke the getView method in the baseAdapter in Android from another WebService Bean?
The adapter in my code as follows, I extends the base adapter code...
View 1 Replies
View Related
Feb 6, 2009
I have one query regarding how to use the services of different APK in my APK. Suppose i have created APK1 having services(serv1, serv2) and APK2. I want to invoke the serv1 in APK2. I have tried by using aidl files also.
These my question: - How we can access services of different .apk. - How to use the aidl file, is the aidl file should be added in the .apk whose service we want to use.
I have gone through the below links, but couldn't find any concret idea of how to impliment. http://code.google.com/android/reference/aidl.html http://minicompact.com/mobiletalk/?tag=android-service http://minicompact.com/mobiletalk/?p=18 http://code.google.com/android/reference/android/os/IBinder.html ..
View 5 Replies
View Related
Aug 11, 2010
I'm trying to make an app where a button will invoke a web service's API call (it'll be my own web service; the call/functionality is not relevant). I know how to make a new listener that invokes an activity, but that is insufficient here since I'll still need to make a call out to a web service through it. What is it I'm doing here? Is this a service that I'm looking at? content provider that I'll be invoking that somehow gets data from a web service?
View 2 Replies
View Related
Nov 1, 2010
I created a method called insertTable in a class called Table but i can't use it in my onClick method in the main class :
CODE:.......
I want to do a income.insertTable in the onClick method but eclipse say that i need to create a local variable.
View 3 Replies
View Related
Oct 11, 2010
I'm not asking to be spoon fed here, just need some pointers on where to direct my searching
I want to call a SOAP web service, possibly this one
I don't want to use KSoap, is there anyway I can do this using the apache libraries that are included with the Android SDK?
View 2 Replies
View Related
Nov 9, 2010
I'm confused about whether I need to run my service in a separate process. What are the advantages / disadvantages of each?For reference I'm trying to create an App that uses a service to play [streaming] audio in the background. So which one is better for my use case?
View 1 Replies
View Related
Sep 30, 2009
i have an app that binds to a local service.I want to add a desktop widget that binds to the same service. does my service have to be a remote service or can it still be local?if it can still be local, how can I get at the local binder?
View 2 Replies
View Related
Nov 7, 2010
I have a custom view that draws to a canvas. I am trying to invoke changes to the canvas when the user pushes a button from the activity that this view is tied to. Currently, I am attempting to do this by calling a public method, called setNewDrawable, that I created inside the view.
The debugger is giving me different values for the view ID depending on whether I'm inside setNewDrawable or inside the Overridden onDraw method when I post an Invalidate.
For example the debugger variables show: (This - MyView id=830067720176) or (This - MyView id=830067712344) in setNewDrawable and onDraw respectively. This makes me think I basically have two copies of the object and I am essentially interacting with the wrong one.
How can I get information to my custom View in order to determine what it draws?
Here is the code I am running...
View 1 Replies
View Related