android-service

cancel Service when user clicks Notification

℡╲_俬逩灬. 提交于 2019-12-12 01:40:02
问题 Similar to this post I got a service that does some work in the background. When the service starts, I'm displaying a notification. Usually you can assing an intent to the notification that is triggered when the user clicks onto the notification. Mostly an activity is then started. But how can I use a notification to inform the background service that the user want's to cancel its operation? 回答1: You can have a BroadcastReceiver to stop the Service, which is triggered through the

Multiple and Repetitive AsyncTask in Android

血红的双手。 提交于 2019-12-12 00:55:47
问题 I have two asynctask working with each other. I'm using them for creating Restaurant menu. First web service gets menu's titles from database. Second web service gets items of title from database. I get title data in my first asynctask and item data in my second asynctask. For example, I have ten menu titles. There are eight items for each title. I execute first asynctask and get all of menu titles. I want to call second asynctask in first asynctask's onPostExecute for get this title's item

ContentProvider or Service?

最后都变了- 提交于 2019-12-12 00:16:11
问题 I am writing an application that shows "Japanese Traditional Time" (JTT for short). There are several components (notification, widgets, application itself, alarms) which all use the same data - current JTT. My current version uses a single service that does all the calculation and uses a Handler to notify everyone about "ticking", mimicking ACTION_TIME_TICK . However with alarms I need to also have a way to translate "usual time" to JTT and vice versa. The calculations are quite CPU-heavy

Android Widget Update service, multiple onclick listeners

♀尐吖头ヾ 提交于 2019-12-11 21:05:58
问题 I have the following widget service which updates a text view when I click on my one button. UpdateWidgetService: ipublic class UpdateWidgetService extends Service { private static final String LOG = "widgetService"; private static final String MyOnClick1 = "myOnClickTag1"; private static final String MyOnClick2 = "myOnClickTag2"; private static final String MyOnClick3 = "myOnClickTag3"; static LocationClient mLocationClient; @Override public void onStart(Intent intent, int startId) { Log.i

Android Sending String from another app

扶醉桌前 提交于 2019-12-11 20:25:38
问题 I am working on two app, ApplicationA and ApplicationB, ApplicationA send String to ApplicationB,and i am display the receiving string on ApplicationB Activity.now everthing is working fine,when i Click on a Button from ApplicationA and want to send a string to ApplicationB,there is popup appear and i am select the ApplicationB from this popup,i want when i click on Button from ApplicationA the popup does not appear and directly my ApplicationB open and display the recieving string,also i

File Cleaning Service

北城余情 提交于 2019-12-11 19:57:51
问题 As a requirement in Android OS phone, I am developing an app which will clean up a particular folder in a specified interval of time, say every 30 minutes. I can run a service and clean up the folder every 30 mins. I have few questions over this, 1.Service has onStartCommand, which will be executed when the service starts, can I call a function here which has a Handler which runs every 30 minutes? Example public int onStartCommand(Intent intent, int flags, int startId){ cleanUpData(); return

Android GPS not working in service

[亡魂溺海] 提交于 2019-12-11 19:39:51
问题 Im trying to get my GPS working in a service but its not working. The GPS bit works on its own but not in the service. I have tried debugging with System.out.println() and fond where it stops working but cant work out why it all looks good. public int onStartCommand(Intent intent, int flags, int startId) { System.out.println("test 1"); LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); System.out.println("test 2"); LocationListener lli = new myLocationListener()

How to restart Android Service when it is killed from Settings

孤人 提交于 2019-12-11 19:34:12
问题 I have an android application that in onCreate method of Main ACtivity starts a Background Service. This is a lightweight Service and I want to keep it running all the time. So , I return START_STCKY in onStartCommand() method of Service. When App is launched and the service starts running,in case,if Only Running Service is killed from the Settings ,and then if App is relaunched ,the onCreate method of app is not called and Service is not restarted. If I start my Service in onResume() method

Android: Activity also calling other Service of the application, which is not called

末鹿安然 提交于 2019-12-11 18:28:07
问题 I creating an android app which basically contains 2 media players . One that plays music from phone memory & other that plays streams from internet(URLs). Each media player is defined in its separate activity . I'm using Service to playback. (i.e. when the user presses the play button, a Service gets started & plays the media). The MusicPlayer is the default activity of the application & is in the package com.example.musicplayer . Whereas, the stream player is in the different package com

Android application as a service without activity

梦想的初衷 提交于 2019-12-11 18:17:14
问题 I am making a set of apps and I have pretty much the same background service for all of them. I'm trying to make an app that has only this Service . so I don't repeat it in all of them, but the thing is don't need any Activity . because there is no UI needed for it, and so the user can't close it except if they stop the Service . I tried to remove the Activity , but then the app doesn't run or start. My question is: can I make an app exactly like Google Play Services so other apps can use its