is it somehow possible to show all broadcast events/intents that are triggered in android? I just want to know if I can quickly figure out if an application is using intents/broadcasts I can hook into. For most of the stock android applications I can read the source but is time consuming.
List all historical broadcasts and registered broadcast receivers with the following terminal command:
$ adb shell dumpsys activity broadcasts
Please check this open source project to see all broadcasts on your android phone:Broadcasts Monitor Pro
There's logcat, which you can get to from the ddms (either the dedicated app, or the eclipse view), it should list all broadcasts, as well as the properties that are associated with the intent. However, as the other commenters on your post have stated, you really shouldn't be doing that unless the intent has been published. It may change, or cause other forms of havoc. Although I disagree with the statement, some people may even go so far as to say that it's illegal if the licenses aren't compatible. (Although I'm of the party that it's not, seeing as you're not statically linking to the code, nor even putting it in your package).
The best tool I found was Intent Intercept that catches the intent on the fly and allow you to inspect the content
Related
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.
So unil this point all I can figure over was that until Android 4.2.2 there were two ways available to us :
Use the logcat and extract information from it
Runtime.getRuntime().exec(
"logcat -v time -b main PhoneUtils:D");
I used this code to read the logcat and find out the displayMMIComplete message here
Use the provided intent named com.android.ussd.IExtendedNetworkService and listen for this intent and do you task.
So what I've acknoweldge until now is, Since 4.0 onwards this intent has been removed and since 4.2.2 onwards printing of USSD message info in the logcat has been removed?
Am I right until here?
And secondly what's the hack or solution now to read the USSD message, there must be some way we can get through it?
There is no Android-framework provided API yet which can be used to "read/intercept" USSD Messages in a Portable way.
The 2 approaches that you mentioned is what was available till now, but as you mentioned, support for it is dropped from Android open source project.
There is a request/discussion going on, which clearly shows that many developers are requesting this feature, but so far there is no update/communication from Google's side to explain future roadmap about adding support to "read/intercept" USSD Messages in a Portable way.
Due to this annoying Android limitation I need users to reinstall my application so the manifest permissions are detected by other applications.
This is already going to be frustrating for the user, but in addition, I cannot see a way to reinstall my application from the apk stored in /data/app and I would therefore have to download the same version to the storage card before firing the usual install intent.
I eagerly await someone telling me that I'm missing something obvious! I've drawn a blank...
Thanks in advance.
Please do star the issue if you'd like to see it resolved! Cheers.
EDIT: With the comments of #hackbod in mind, you can use the following code to initiate the install dialog.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(this.getApplicationInfo().sourceDir)),
"application/vnd.android.package-archive");
startActivity(intent);
On my Jelly Bean device, this presents two options: Package installer and Verify and install. I don't know if the latter will deal with the issue of:
Installing your app this way will probably remove ownership of it from the Play Store
My application is free, so I cannot test the paid issue of:
Note however if your app is forward locked (which is unavoidable for all paid applications starting with JB, due to the app encryption), then this won't work because your app executable is not readable by others
Although hackbod finishes with 'readable by others' which suggests that if you are executing this through your own code, for your own application, it is readable? Please do correct me if you can test this and I'm wrong.
Conceivably you could just get the path to your .apk through Context.getApplicationInfo().sourceDir, and launch the app installer with that path. Not however if your app is forward locked (which is unavoidable for all paid applications starting with JB, due to the app encryption), then this won't work because your app executable is not readable by others. In that case you would need to copy the .apk to somewhere world readable (such as in external storage) and install it from there.
No matter what you do here, though, this has some unavoidable very negative consequences:
The only way to do any kind of install from your app is to go through the side-loading UI, which is (a) going to be a very scary experience for the user, and (b) will require that the user turn on side-loading to be able to proceed.
Installing your app this way will probably remove ownership of it from the Play Store (since it is no longer the one that has installed it). This may mean for example that the user can no longer report crashes or ANRs to you through the play store, or other negative consequences. I am not sure exactly what problems will actually happen here, but I really wouldn't assume that this is going to be okay.
Ultimately, I just would very much not suggest doing this. What permission are you needing that is forcing you to do this? For many reasons, I wouldn't recommend that third party applications declare their own permissions in most cases, because there are a lot of bad user experiences around permissions that are only known after they may have been needed.
I was thinking to build up an app to manage the notifications. I gave a look to the Notification Manager but i didn't find anything that could help me. I'd like to get all the notifications (that are in the notification bar). Have you got any idea? Thanks, regards.
I don't believe there's any possibility to do such thing using the public API. There are strict restrictions to what an app can access, for obvious security reasons. Each app is handled as a different user by the OS, so it has access only to public data and to the data owned by that app.
If you need this for a private project, you may consider modifying the android source code. I can't give you many details on how to do it, but I would start by looking at com.android.server.NotificationManagerService (source code here).
I have some code that will launch a different application using intents but what can I do to close or kill the other app?
Here is the launch code (works great):
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setComponent(
new ComponentName(resolveInfo.activityInfo.applicationInfo.packageName,
resolveInfo.activityInfo.name));
I tried to kill the background processes but no luck:
ActivityManager activityManager = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE);
activityManager.killBackgroundProcesses("com.pandora.android");
I also tried this to kill it:
context.stopService(new Intent(context, Class.forName("com.bla.bla")));
Update:
I want to kill other applications because I launch other applications and users have requested this additional feature (auto kill is a natural extension of auto launch). Please answer the question of how to accomplish this in code. I know about Advanced Task Mgr so it is possible but how?
I ended up finding the real answer to this question. Please see Automate closing of applications in Android for the solution!
but what can I do to close or kill the other app?
You don't. Your user can exit that "other app" when they wish to.
Basic answer, you can't. As of Froyo, the only facility available is ActivityManager.killBackgroundProcess(), which:
(a) Only allows you to kill processes that are, as it said, in the background and not visible to the user. That is, it does not allow you to disrupt the normal execution of the other app.
(b) Is not needed anyway, because Android will kill the background processes for you if it needs their memory.
You simply do not need to do what you at this point seem to think you do. "Because my users have asked for it" is not a reason to be going around killing other people's processes.
The only proper way to kill another "App" would be to send some kind of Intent to the app (ex. Pandora) or it's service that will ask it to exit.
Task killers use facilities outside of the normal means of Android like Process.killProcess() that talks to the Linux Kernel and not Android. The problem with that approach is it does not tell Android to close the program, but instead the Linux Kernel directly. If a background service is killed, for example, without calling Context.stopService(), Android may restart it later automatically. Also, killProcess doesn't just close the Activity, it kills all the components and doesn't allow them to shutdown normally.
If you started Pandora with Activity.startActivityForResult() you could try closing it with Activity.finishActivity(), but there's no guarantee that it will work the way you want it to.
You can use Process.killProcess()? you need to know the PID. To get the PID, you can exec "ps", but that's not going to be robust as the text output format could be different across devices or releases. You could provide your own native library to gather the process names and IDs into a standard format for your own purpose.