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.
Related
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.
I'm looking into starting an Activity (different app) with some parameters (sensitive session) and was wondering what's the safest way here. For instance, startActivityForResult() may be used on Android and I was wondering if any other app can see this request or if it requires root rights to intercept such a request? So basically, is it safe to use it or not? By default, we assume users don't have root rights.
I was wondering if any other app can see this request
The app that responds to your startActivityForResult() call can see the request. That could be:
The real unmodified app that you wish to send the data to
A hacked version of that app
A completely independent app that happens to match your Intent, particularly if you are using an implicit Intent
You can try to check signatures to confirm whether the other app is indeed the real unmodified app, so you avoid the latter two scenarios.
On older versions of Android, the Intent would be visible to other apps as part of the data backing the overview screen (recent-tasks list). That was cleared up somewhere in the 4.x series IIRC.
Those are the only two attacks that I know of for non-rooted devices.
After a user opens my application I don't want them to be able to get out. So when they press the home or back button it doesn't let them exit the app. I know there are ways using a service to keep the app always running in the background, but I don't even want them to even exit.
Is this even possible, if so how? Without having to hack the kernel.
I know this sounds odd, but it is not for a commercial app, but for my lab, it will never be on GooglePlay. The tablets will be given to little kids and they will take a test on it, so I can't have them using youtube or anything else.
Related post: Android, How to make the task of the app unclosable? Only closable by task killing
The answer by CommonWare seems to indicate that kernel hacking is the only way, but is it?
Also I am using Android L.
there is no official support yet - there will be support with android L via the Task locking API
The L Developer Preview introduces a new task locking API that lets
you temporarily restrict users from leaving your app or being
interrupted by notifications. This could be used, for example, if you
are developing an education app to support high stakes assessment
requirements on Android. Once your app activates this mode, users will
not be able to see notifications, access other apps, or return to the
Home screen, until your app exits the mode.
https://developer.android.com/preview/api-overview.html
EDIT: as you said you use L this got obsolete - but I leave it here as a hint for others
said that - you are also able to get this kind of work without root today if you have to ( e.g. kiosk mode app on a certain hardware ). It is not simple - and no solution that works for all devices - but if you need it you can get it work with tricks like:
- reacting on home-screen intent ( and setting it as default )
- when you go to background - bring your self foreground again
- ..
It seems google has some thing called COSU for setting up single-purpose devices
Android 5.0 Lollipop introduced two new ways to configure Android
devices for a single purpose:
With app pinning, the device user can temporarily pin specific apps to the screen.
With lock task mode, a user can’t escape the app and the Home and Recents buttons are hidden. Additionally, lock task mode gives the IT
administrator a more robust way to manage COSU devices, as discussed
below.
and
As an IT administrator, you can configure Android 6.0 Marshmallow and
later devices as corporate-owned, single-use (COSU) devices. These are
Android devices used for a single purpose, such as digital signage,
ticket printing, point of sale, or inventory management. To use
Android devices as COSU devices, you need to develop Android apps that
your customers can manage.
from here
and there is a code lab for it here
for earlier versions of android here i founded How-To Create a Working Kiosk Mode in Android which shows some hacks for disabling buttons and restarting the application after boot and lock. note that most of these hacks, don't work on android 6 and later
I am currently trying to find a way to programatically inject items into a mobile browser's cach on Android devices. The browser type doesn't matter, it can be Firefox, Chrome, Android's built in browser, etc.. Is there any documentation or examples of ways to programatically inject objects into the browsers of Android devices?
Not really an answer, just a heads up. Seeing that your question is tagged java, I assume you want to do this from an application, and not from the browser. I'm pretty sure that's impossible, because each Android app is running in it's sandbox. Communication between apps is done through Intents and IPC. In both cases, you are limited by what the target app is offering support for.
You can use proxy, to get this structure :
Client => Your APK => Server
(Like this application).
With your APK you can choose file to send.
Like already mentioned by Corneliu, its impossible for an normal android app to write into the data section of another app.
Although it should work when the phone is rooted. Apps like TitaniumBackup which require root can read and write the data saved by other apps. You can use TianiumBackup to make a backup of the browsers and look in the *.tar.gz file for the internal data structures and the SQLite DB files...
I've gotten an android service written as a stand-alone APK and I'm trying to include this in the SDK so it automatically installs the service through some publicly exposed function from the SDK.
Is there a way to achieve this?
For instance, the SDK is monitor.jar which has helper functions.
The service is GetCurrentMonitor.apk which runs a background service that returns the value of some stock currently monitoring.
Now, I want to release the SDK so that when it's included in some 3rd party app, it automagically installs the background service for GetCurrentMonitor project...
Any help is greatly appreciated.
Thank you,
Your question is very confusing. Here is my interpretation of what you are asking:
I have an Android application that has a service. I have a separate SDK (JAR or Android library project). I want users of the SDK to be able to call a function and have the APK containing the service be downloaded and installed.
This is possible, sorta.
You can have code in your JAR that either:
call startActivity() on an ACTION_VIEW Intent for the market: Uri pointing to your app on Google Play, or
downloads an APK from some server of yours to external storage, then calls startActivity() on an ACTION_VIEW Intent pointing to that downloaded APK, to kick off an install
In either case, the user will need to get involved in the installation process -- you cannot install apps silently. And, in the latter case, you will be responsible for handling your own updates over time.
This also will tend to confuse the user, as they may not realize why your app is floating around their device, so you will need to be able to handle the case where they uninstall it.
Also, it is possible that on Android 3.1+, the user will need to launch an activity of yours before your service will be usable. With luck, that is not required, though I cannot rule it out at this time.
And, of course, if I did not correctly understand your question, please consider editing the question to clarify what it is you are trying to accomplish.