android-background

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

两盒软妹~` 提交于 2019-12-02 03:02:17
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 backstack fragment A ( activity.backpressed()) 4) Now, I have a scenario where I am calling fragment B, by

Update data in Background Periodically (Android)

最后都变了- 提交于 2019-12-02 02:19:28
The main objective of my app is, when a button is pressed: Collect data from the sensors Store data in the database Repeat periodically (every X seconds) I want to have it done in background, and if the Main Activity is destroyed, the background progress to be still running. So if you delete the activity, I want it still running. What I am doing right now, is having an AlarmManager with an Intent Service , to set the periodic recording of the Data, but whenever I destroy the Activity , as they are related, my app crashes. I know there are different to run a background process, but none fits in

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

血红的双手。 提交于 2019-12-01 14:50:43
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 in MIUI 8 in setting >Permissions>Autostart you can allow your app to Auto Start and Facebook and WhatsApp are already allowed because MIUI

What is the expected behavior of SQLite CRUD operations after a configuration change or if the activity that started those operations is destroyed?

為{幸葍}努か 提交于 2019-12-01 08:14:40
问题 I'm refactoring an app I made some time ago. Back then I was taking my first steps into Android and the easy way to go was to avoid orientation changes, for almost all my CRUD operations I used the AsyncTask class, didn't implement a Content Provider or used Fragments. Now I have made some changes: I use Fragment s to encapsulate functionality All accesses to my database are done through a Content Provider I use CursorLoader s to retrieve my data taking advantage of the content observation

Background execution not allowed receiving intent BOOT_COMPLETED

南楼画角 提交于 2019-11-30 01:24:17
问题 I've read about Android Oreo background execution limitations, and it clearly states that BOOT_COMPLETED broadcast is unaffected, but I can't get it to work on Android Oreo. First, I am compiling against SDK 27. Secondly, I declared the receiver inside the manifest file: <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <receiver android:name="helpers.StartDetectionAtBoot" android:label="StartDetectionAtBoot" android:enabled="true" android:exported="true"> <intent

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

半腔热情 提交于 2019-11-29 05:12:46
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) v).setTextColor(Color.BLACK); } } }); Which is called in the onCreate method like this: edittext =

Set “allow” permission by default in “Asus auto start manager” from code

不想你离开。 提交于 2019-11-28 17:38:18
I have an application which needs to run in the background, so I'm using a WakeFullService for that. But in Asus Zenfone it's not working because Auto start manager does not allow the app to run. My expectation is: To set "allow permission" in auto start manager during our app install or at the time of app opening. Is there any API available from ASUS Auto Start Manager which can help me check the permission status of my app so that I can notify the user via normal text alert to turn on the permission. Someone did it for Huawei: "Protected Apps" setting on Huawei phones, and how to handle it

How can I convert String to Drawable

时光怂恿深爱的人放手 提交于 2019-11-28 07:48:52
I have many icon in drawable folder and I have their name as String. How can I access to drawable folder and change background imageView (or any view) use these name in dynamically. Thanks This can be done using reflection: String name = "your_drawable"; final Field field = R.drawable.getField(name); int id = field.getInt(null); Drawable drawable = getResources().getDrawable(id); Or using Resources.getIdentifier() : String name = "your_drawable"; int id = getResources().getIdentifier(name, "drawable", getPackageName()); Drawable drawable = getResources().getDrawable(id); Then use this for

Scale image keeping its aspect ratio in background drawable

怎甘沉沦 提交于 2019-11-27 18:40:24
How do I make a background image fit the view but keep its aspect ratio when using <bitmap /> as a background drawable XML? None of <bitmap> 's android:gravity values gives the desired effect. It is impossible to achieve manipulating background attribute within xml-files only. There are two options: You cut/scale the bitmap programmatically with Bitmap.createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter) and set it as some View 's background. You use ImageView instead of background placing it as the first layout's element and specify android:scaleType attribute for it:

Set “allow” permission by default in “Asus auto start manager” from code

你离开我真会死。 提交于 2019-11-27 10:52:23
问题 I have an application which needs to run in the background, so I'm using a WakeFullService for that. But in Asus Zenfone it's not working because Auto start manager does not allow the app to run. My expectation is: To set "allow permission" in auto start manager during our app install or at the time of app opening. Is there any API available from ASUS Auto Start Manager which can help me check the permission status of my app so that I can notify the user via normal text alert to turn on the