intentservice

When to unregister BroadcastReceiver? In onPause(), onDestroy(), or onStop()?

牧云@^-^@ 提交于 2019-11-27 13:31:03
问题 When should I use unregisterReceiver? In onPause() , onDestroy() , or onStop() ? Note: I need the service to run in the background. Update: I get an exception releasing receivers null . Activity has leaked intent receivers are you missing call to unregisterReceiver(); Please tell me if there's something wrong, here's my code: private boolean processedObstacleReceiverStarted; private boolean mainNotificationReceiverStarted; protected void onResume() { super.onResume(); try { registerReceivers(

How to Collect info from IntentService and Update Android UI

断了今生、忘了曾经 提交于 2019-11-27 12:02:38
问题 I'm learning Android and I'm stuck with my service. My application connects via Socket to my server every X seconds, receives an XML, parses the information and it's shows in a TextView. I'd like to know how can I implement an IntenService to do this and how to communicate the info to the UI. I'm finding very hard to see good examples. I appreciate any help you can give me. Thank you! 回答1: Use a handler and send a message to parent activity from the intentservice Parent Activity : Declaring

How to force an IntentService to stop immediately with a cancel button from an Activity?

时光怂恿深爱的人放手 提交于 2019-11-27 11:33:35
I have an IntentService that is started from an Activity and I would like to be able to stop the service immediately from the activity with a "cancel" button in the activity. As soon as that "cancel" button is pressed, I want the service to stop executing lines of code. I've found a number of questions similar to this (i.e. here , here , here , here ), but no good answers. Activity.stopService() and Service.stopSelf() execute the Service.onDestroy() method immediately but then let the code in onHandleIntent() finish all the way through before destroying the service. Since there is apparently

Need Help in Downloading in Background Images in Android?

别等时光非礼了梦想. 提交于 2019-11-27 11:15:52
I have an image view , i had written swiping , at that time of swiping,the images are downloading from Internet, so i thought i have to download the images in the background before swiping , for that which i need to use asynctask or Service or IntentService, all these will help in downloading and storing in data/data/mypackages , but still swiping gets slow in my case any idea, also convey me which one is best one, is it i'm calling in a right way 1. asynctask 2. services 3. Intent Service as shown below, i m confused which one is right method because still my problem not solved Here's

How to use CPU to perform any operation in Deep Sleep mode

不打扰是莪最后的温柔 提交于 2019-11-27 09:51:47
I'm new in android . I struggle with my application approximately 3 weeks. I need sent and receive packets in normal mode and sleep mode . My app must exchange data a 5 seconds. I tried using alarmmanager but on android 5 it's not works. On android 5 an interval changes it on 60 seconds. Such a solution makes the battery wears out quickly. When I use normal asynctask, not IntentService , then it works only when screen is ON and app is visible. When app is hidden or I click power OFF then exchange data stops working. What is the best solutions? Even RTC_WAKEUP doesn't help most of the times.

Should I use AsyncTask or IntentService for my application?

三世轮回 提交于 2019-11-27 09:50:03
问题 I have been reading around on internet connectivity with Android and noticed there are different ways to handle this i.e. AsyncTask and IntentService. However, I'm still not sure which one to use. My application is basically a location/trails finder with Google Maps. My internet connectivity will be used to find the nearest trails within a certain radius of the map. So, every time a user moves or swipes the map to a new location then it will update with the nearest trails. It will also add a

Proper way to stop IntentService

若如初见. 提交于 2019-11-27 09:03:01
I'm using an IntentService to upload images to a server. My problem is that I don't know how/when to stop the service. When I call stopself() in onHandleIntent(Intent ..) all Intents which are waiting in the IntentService queue are removed. But I don't want to stop the service from an activity because I want to complete upload proccess even if my application is not running. My problem is that I don't know how/when to stop the service. IntentService automatically stops itself when onHandleIntent() ends, if no more commands had been sent to it while onHandleIntent() was running. Hence, you do

How is an Intent Service Declared in the Android Manifest?

情到浓时终转凉″ 提交于 2019-11-27 04:35:43
Straight forward question: Is an IntentService declared in the Android Manifest as a regular service, or is there another way? It tried searching for it, but I couldn't find the answer. Here is the regular Service declaration: <service android:name=".NameOfService"> </service> Thanks In your manifest you declare a service with android:name=".Communication" , this means that your service class should be located in com.exercise.AndroidClient.Communication Check that the packages are correct. Note that the "." (dot) refers to the root of your package (ie the package declared in the manifest). So,

send intent from service to activity

末鹿安然 提交于 2019-11-27 03:51:30
I'm trying to return the result from an IntentSerivce to the mainactivity using an intent, but I can't get it to work. The IntentService receives the intent from the activity without a problem, does it's thing and gets a JSONstring . Now the only problem left is to send this String back to the activity. Here is the method in the mainactivity: public String RTConn(String query){ System.out.println("Querying Rotten Tomatoes."); Intent rtIntent = new Intent(MainActivity.this, RTConnection.class); rtIntent.putExtra("query", query); bindService(rtIntent, RTConnection, Context.BIND_AUTO_CREATE);

Send location updates to IntentService

≯℡__Kan透↙ 提交于 2019-11-27 02:47:36
问题 How can location updates be sent directly to Intent Service? The following approach does not work. OnConnected function is called but then the intent is never received in the service: ... private PendingIntent getLocationPendingIntent(boolean shouldCreate) { Intent broadcast = new Intent(m_context,LocationUpdateService.class); int flags = shouldCreate ? 0 : PendingIntent.FLAG_NO_CREATE; return PendingIntent.getService(m_context, 0, broadcast, flags); } @Override public void onConnected(Bundle