Cannot access/control ongoing downloads after closing and reopening the Android app - java

My android java app has Offline Video feature like the YouTube app. I do not use android.app.DownloadManager because it does not support pausing the downloads(or as I know).
I have been using a third party download manager library(tonyodev.fetch2) and it does the work done but the problems are:
How can I make the download independent of the app closing/opening etc and also being able to control it when required from an Activity.
If I use a Service for the above problem, what do I use, IntentService or just normal Service keeping in mind I have to know about the ongoing downloads and control it(pause/stop/resume) from any activity.
I have been using android worker class which extents ListenableWorker but I cant seem to make things work as required.
I have been struggling with this for a long time now any help is welcome, or a totally new approach for this particular problem.

Related

Is it possible to know the app which is opened currently?

I am a beginner in android development. I want to know that is it possible to know the app which is opened currently. I came to know that finding the apps which are running currently through Activity Manager (getRunningTasks()) is now removed from the Android studio. So I want to know is there any other way to know? I just want to know the app which is opened and running currently on the mobile but not the apps running in the background Could somebody please help me in this case?
You can use AccessibilityService to get event notification. But AccessibilityService are specifically for accessibility uses. If you use the service for other purposes, then the application will more likely to be downed/removed for PlayStore due to policies. Another viable option is UsageStatsManager, but with some limitations.
UsageStatsManager is not push event based system. You have to poll in few mills(depends upon the use-case)
Usage Access Permission grant/deny is not straight forward. You have to start Setting Activity with Settings#ACTION_USAGE_ACCESS_SETTINGS action and have to rely on the users understanding of how to grant permission(Since permission list may contain other applications).

How to create a loopback camera through Android HAL?

1\ Regarding to Android Source Project hosted by source.android.com, Android supports multi-camera functionality. Also we have some information about how a camera driver really works in Android.
2\ As you know there is an old project called v4l2loopback that you can install and run on your Linux (it's simple if you have root access). For example you can also have fun with ffmpeg to stream a video as a dummy webcam device. (v4l2virtualdevice_android)
Qust\ What I'm really watching for is simple in logic and hard to develop. I want a solution that my Android application (that is provided as an APK) will be able to create a dummy camera and I can feed that from another source (not really important; maybe a video file). So user will be able to use original camera app, Instagram app (Live), etc ... to record the video.
I don't really know if it's necessary for device to be root or not. And if it's possible how can it be done using java or NDK?
You can do that if you replace the system camera HAL. It's quite possible if you build a custom ROM. Having root access on a known device is essentially same as having your custom ROM. But this doesn't help if your APK is installed (with root access) on a different device, even if the changes are minimal. Sure you can prepare logic that will work on many devices, but each will require separate consideration and testing.

Which app launched my app?

I have an Android app and have registered a custom URL scheme. Is it possible to get what app launched my app (e.g. Facebook, Chrome etc...)? At the moment, I can only find how to get the URL that was clicked but not the actual app that launched mine. Can I do this or am I chasing something not possible?
Thanks
No, you cannot.
Unless, of course, you have defined a proprietary protocol where the calling activity includes the name of itself in the intent, and you are in control also of the calling applications. Obviously this would not work for cases such as finding out if Chrome or Facebook called you as you don't control these apps.
You might have some limited success using ActivityManager.getRecentTasks() and try to find out which app is #2 in the task list, but that API is deprecated in Lollipop, and can not be trusted on older platforms either, apps can choose to be excluded from recent tasks, your app could be spawning a new task vs be part of the calling apps task, etc.

"One App" Android System

I created an Android app which communicates via USART with a µC in order to evaluate data. My co-workers and customers should use the tablet for only this purpose now. Is there any possibility to "hide" the Android OS or making it inaccessible?
Devices are rooted and I am willing to build custom ROMs (even though I do not have any experience with that yet). Are there any approaches available that I do not have to start from scratch?
Many thanks for your help.
Well. That what I'm trying to do !
The first thing I tried was to start the app just after the boot of the device (Quite easy with this).
Then, I get Android source code, and I hide the bottom bar using this code
The problem is, if your application is not stable ... you'll have some problem.
If you want to modify Android source code, the developper doc contains a very good tutorial to start !

background threading in android

I am a research student who just started the android programming for 3 weeks and I am trying to write an App which extracts data from accelerometer from the phone and writing it on my phone. My problem is that I would like to run my App (taking data from accelerometer) all time when the phone is up and running. What I mean is that my App has to run all time when somebody is calling, facebooking and so on. Is that possible? I would like to get some references.
What I mean is that my App has to run all time when somebody is
calling, facebooking and so on. Is that possible?
So for long-tasks you can use AsyncTask or Services. If you want to execute some task and it have to run also when its not connected with any Activity(for example Music player, RSS which still run also after release from memory by memory manager), you should decide to use Services and also you can combine Services with AsyncTask.
Services are strong tool but work with them is not trivial. You are able to execute only one Service in time and only one Service can running, one instance, one copy. This all is not free so you have to be careful because when you implement Service too dirty, it may cause premature exhaustion of battery.
There is more approaches how to start Services but you have to read some tutorial and guides.
I recommend to check this: Services, ServicesDemo - Using Android Services, Android Service Tutorial, Local Service | Android Tutorial for Beginners
Also have look at AsyncTask, Android Threads, Handlers and AsyncTask - Tutorial
You can use Services. Look here
If you want your activity of your app to be closed, but still a process should be running at background doing your desired work, then you can use Service, or IntentService (Use intent service, in place like, you want an update after certain period of time).

Categories

Resources