android-background

Bind to service from new Context for configuration changes or bind from app context?

别等时光非礼了梦想. 提交于 2019-12-20 09:41:43
问题 I'm trying to work out if bound service is appropriate for doing background work in my app. The requirements are that various application components can make web requests through it of varying priority. (Thus the service must maintain some sort of queue and be able to cancel it's ongoing requests for others of higher priority). I'd like the service to be relatively unobtrusive to the user such that they don't find it running after they are done with the application - if I want to do something

EditText - change background color of text (and only text - not the whole view)

那年仲夏 提交于 2019-12-18 04:26:15
问题 When a user enters information in an EditText, and moves to the next EditText, the information is highlighted as shown below: The code for this: edittext.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { v.setBackgroundColor(Color.WHITE); ((EditText) v).setTextColor(Color.BLACK); } else { //v.setBackgroundColor(Color.LTGRAY); //also works like this ((EditText) v).setBackgroundColor(Color.LTGRAY); ((EditText)

Draw multiple lines on a RecyclerView background

末鹿安然 提交于 2019-12-13 21:18:11
问题 I'm trying to draw multiple horizontal lines on a RecyclerView background. These lines have to be at a precise position, because there is a list of elements which have to fit between them. I could just add the lines to each element but I need those lines drawn, even if there are no elements added to the list. How can I draw lines on the background? (I can't do it from the .xml) Thank you for your time! Example image 回答1: It looks like you want to draw list dividers. I think you want to use

When I clear all recent apps, android system kills my app service on Android v7.1.2

偶尔善良 提交于 2019-12-13 02:49:57
问题 enter image description hereI want to create an app which runs in the background. I have tried all stackoverflow solutions. Those solutions are all working when the app is cleared by myself. But when I'm performing "clear all recent apps". The service stops. I'm using Android v7.1.2 Android Nougat. @Override public int onStartCommand(Intent intent, int flags, int startId) { log("Received start command flags:%d, startId:%d", flags, startId); Notification.Builder builder = new Notification

How do I retrieve the previous fragment upon opening an app from background? (app that wasn't killed)

邮差的信 提交于 2019-12-13 01:42:53
问题 I have a pretty unique issue where I am trying to retrieve previous fragment that was there before I went to the homescreen via the current fragment( last visible fragment) Not to confuse any further, here's the steps to repro my issue 1 ) launch the mainactivity, from there open fragment A via a button click (say button A) 2) from fragment A , press another button ,say B, which will open fragment B. 3) Fragment B has a close and save button , pressing which leads me back to the previous

Starting activity from Service when phone is locked Android 9.0(Pie)

烈酒焚心 提交于 2019-12-11 06:07:34
问题 Hello I'm working on VoIP feature for the app and I'm trying to handle cases when app is killed. My idea is to go with FCM notification and run activity which will show user incoming call screen. It works as expected when phone is unlocked but not the case when phone is locked. I tried this : if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O_MR1) { setShowWhenLocked(true); setTurnScreenOn(true); }else{ getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); getWindow()

Run Gps as background service and Compare the received current Location Data with value in Sqlite?

风格不统一 提交于 2019-12-11 04:49:50
问题 I know there are many questions that have been asked regarding this and i have been going through all that from couple of days but couldn't find a reasonable answer.I am newbie to android so i have no idea how things get done. Basically I want to know how to run GPS as a service in background like when the application is installed it starts and how to compare that data received from gps background service with data in SQLite Data Base. 回答1: you can make service like above , this service get

Android - How to download a large nos of images (large nos of http url) in Background Process

让人想犯罪 __ 提交于 2019-12-10 11:47:21
问题 I am getting a list of image url from server whose count is approximately in between 400-500. How can i download this image in background into local folder of the device ? SO far i have run a foreground service in which i am using ExecutorService to run a thread. My service code is below public class SaveImageService extends Service { private Context context; public static final String NOTIFICATION_CHANNEL_ID = "10001"; public SaveImageService() { } @Override public void onCreate() { super

How to restart Background service getting killed on redmi phone For MIUM 8

自作多情 提交于 2019-12-09 03:27:10
问题 I am using sticky service for background operations and its working fine in all phones even when app is closed by swiping from stack(then service is restart) but in RedMi Note 3w When app is closed by swiping from stack , service is not restarting .I test Whats App and its working fine on Note 3 so it means WhatsApp is able to manage this so how can we restart Background service getting killed on redmi phone? Note : please don't give me solution for MIUM 7 回答1: in MIUI 8 in setting

Changing TextView background color on click android

妖精的绣舞 提交于 2019-12-05 23:17:36
问题 I'm trying to change the background of a textview when clicked. For instance, if the textview is click it the background changes to yellow and remains yellow until it is click again. Then it returns to its default background. Currently textview the background changes on pressed down, but returns to default on release. I have search the internet for solutions and look at most of all the solution on stackoverflow, still no solution. Drawable/selector.xml: <selector xmlns:android="http://schemas