intentservice

How can my IntentService in background always listen to device's shake?

▼魔方 西西 提交于 2019-12-08 08:28:32
问题 I am developing an app which is basically one widget and one service. The widget is only a button which I want it to run the service in the device's background. So the user just clicks the button and nothing happens in the UI, the service starts in the background. But I want the background service, which I have implemented using IntentService, to ALWAYS listen to my device's shake in the background after the widget's button is clicked. It has to monitor the accelerometer sensor for any change

Check network connectivity android

你。 提交于 2019-12-08 05:57:34
问题 I am new using Service in Android and I am quite confused. I have and Activity and I want to check for all the time that the network connection is up (wifi or 3g). I implemented a simple Service and a BroadcastReveiver . here the code of the Service public class NetworkCheck extends IntentService { private final String CONNECTION = "connection"; public NetworkCheck(String name) { super(name); } @Override protected void onHandleIntent(Intent workIntent) { ConnectivityManager conMgr =

IntentService connected to Server listening

。_饼干妹妹 提交于 2019-12-08 04:13:11
问题 I coded an IntentService where I send a command line. Is related to an activity where I'm trying to program a Console. The activity's purpose is to do a 'command prompt' where I can send and receive to/from the server. The Service's action is: COnnect to the server Send command line Get response Retrieve response to user The main problem is that every time I send a command line, the Service has to reconnect to the server. (Cause every time I'm starting the whole Service) How can I avoid this

IntentService connected to Server listening

本小妞迷上赌 提交于 2019-12-08 03:58:25
I coded an IntentService where I send a command line. Is related to an activity where I'm trying to program a Console. The activity's purpose is to do a 'command prompt' where I can send and receive to/from the server. The Service's action is: COnnect to the server Send command line Get response Retrieve response to user The main problem is that every time I send a command line, the Service has to reconnect to the server. (Cause every time I'm starting the whole Service) How can I avoid this step? I would like to "keep alive" the service waiting for a command line to send, without the need of

How to wait for an IntentService to finish its task

孤街浪徒 提交于 2019-12-08 02:58:24
问题 I'm using an intent service to communicate with a server to get data for an app. I'd like the app to wait until the data it requests has been sent back (hopefully meaning that the IntentService the data has been requested from has finished running) before the app attempts to access or use the variables the data is to be stored in. How would I go about doing this? thanks! 回答1: Easiest way is to have your IntentService send a Broadcast once it is done gathering data from the server, which you

Android中X5WebView详解

依然范特西╮ 提交于 2019-12-08 01:02:51
今日科技快讯 据路透社报道,推特(Twitter)公司周五宣布,它已经禁止总部位于莫斯科的卡巴斯基实验室在其社交平台上打广告,称这家网络安全公司的商业模式与其广告规则存在冲突,并援引美国政府的说法称卡巴斯基实验室与俄罗斯情报机构有关联。推特通过电子邮件证实了这项封杀令。 作者简介 欢迎回到周一,新的一周继续加油努力吧! 本篇来自 骑小猪看流星 的投稿,分享了他如何封装 X5WebView以及如何在项目中灵活运用的过程 ,一起来看看!希望大家喜欢。 骑小猪看流星 的博客地址: https://www.jianshu.com/u/0111a7da544b 前言 这一篇的目标就是怎么样快速封装X5WebView,如何有效的同步以及管理Cookie,使用IntentService优化预加载,如何监听进度条等一些在项目中使用的常用功能。 正文 功能需求 需求一:客户端账号密码登录成功以后,调用H5界面(也就是使用X5webView,以下简称X5)。H5界面也需要去记录你的状态,比如你客户端本地登录成功以后,H5界面也需要显示登录成功的状态。那么,客户端和H5如何去同步状态? 需求二:因为X5加载的时候,会有一段时间会显示空白或者卡顿,如何去监听并利用这个进度并优化? 需求三:如何简单封装X5WebView基本功能? 需求分析 需求一 (针对需求一,我真的是参考了很多哥们的技术博客

Service and IntentService, Which is better to run a service that poll database value from the server?

放肆的年华 提交于 2019-12-07 23:50:56
问题 I had read quite a number of resources regarding the Service and IntentService . However when come to make a decision, I am not confident enough to choose which type to use in order to create a background service that will poll data from database in a time interval and stop it when I get the data I want since the data represent a status of a request, eg. ordering medicine confirmation status(pending, completed, in progress). I need to detect when a status is set to "completed" and send a

Android Thread vs AsyncTask vs IntentService called from BLE onCharacteristicChanged()

為{幸葍}努か 提交于 2019-12-07 23:31:36
问题 I have an Android app from which I receive BLE data (every 62ms via notifications). The app can save data via a BufferedWriter to a file. Upon each onCharacteristicChanged() callback, I call either an AsyncTask, Thread or an IntentService to do a file write if the user enabled file save. The AsyncTask seems to work fine. But the docs say execute must be invoked on the UI thread, and I'm calling it from the BLE callback. Is that a problem? And how should I fix it? Using Thread causes this

Reasons why an IntentService won't start? [closed]

早过忘川 提交于 2019-12-07 11:58:57
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have an Android IntentService that is behaving strangely. I am sending it an intent via a call to startService(intent). (I apologize, I'm away from my desk and can't paste any actual code.) When I make the

Stopping an IntentService

元气小坏坏 提交于 2019-12-07 06:05:43
问题 Does anyone know if there is a way of stopping an IntentService without it finishing its work thread and stopping itself? Simple question, but I couldn't find the answer in the documentation. Is there a simple way of stopping it? Thanks 回答1: bevor a message to a service is enqueued onStartCommand is called. which forwards the message for queueing. so you could just override onStartCommand, something like that: @Override public int onStartCommand(Intent intent, int flags, int startId) { if