I'd like to invoke third-party apps to enhance my own. For instance, I'd like to allow users of my app to use programs like CamScanner to capture images as an alternative to the camera. I'd like to be able to suggest recommended third-party apps that work well as intent alternatives to bring better functionality to my app.
Is there a public manifest after installation or better yet some indication in the Play market page for the app that shows which Intents it supports?
there is http://openintents.org - if it is listed there.
You can learn about activity names from the system Settings/Applications screen.
No matter what, you'll be able to invoke their main activity, like this:
startActivity(getPackageManager().getLaunchIntentForPackage("com.theirpackage"));
Now, non-main activities that are not explicitly documented are another matter. Even if you get the manifest text, this might or might not help you figure out the invokation protocol; the activity might rely on intent extras that the manifest says nothing about.
And no matter what, you never know if the activities in the app rely on a certain order of invokation. Unless an activity was explicitly built for third party reuse, you never know if it's ready for reuse. I can easily envision the scenario where an activity relies on a static variable that's initialized in another activity, which is always started first over the normal flow of the app. If you invoke the dependent activity out of order, be ready for crashes.
That said, it's fairly easy to get the XML manifest for an app. First, get an emulator image with Google Market in it (search around, those are all over the 'Net), or a rooted device. Install the app from the Market. Pull the APK from the device using ADB or Eclipse. Then use the apktool to take the APK apart. It decompiles the manifest into a readable XML form.
In case of the CamScanner app, it exists a public API.
https://dev.camscanner.net/
It requires to sign an agreement.
Related
Currently I am building an app and in IOS the users get the choice, what to do with the content. The most important activities are 'Copy' and 'WhatsApp'. Options are given through the activity viewcontroller as seen in the example image below:
This is build in Xamarin so the activity view controller is called through an IOS dependency. I am not very familiar with Android and I was wondering if android has something comparable?
(And what is it called, I could not find any hits on google with android and activity view)
If it exists and I know how it is called, I can use it for android in the Android dependency.
In Android, you can "talk" to other apps even if you don't know them, simply by telling the OS, "Hey, I have this data type, that I want to share, can you show the user apps and actions that can handle it so he/she can decide?"
They are called Intents (get it? :p)
Anyway, there's basically the official documentation about how to do this. So I suggest you refer back to it (and other readers of the future) for things may change between releases.
The short answer is: fire an intent indicating what you want to share, and let Android do its thing.
I am trying to archive same thing as done in "hierarchyviewer" tool, which dumps the tree of Views present at any given moment on the device or emulator screen.
But i want it to be an Application running on a Android device. This app will keep running in background like a Serve and will dump the currently displayed Views in a text file.
Is it possible? is there any code examples are available?
Is it possible?
No.
The closest you can come is to implement an AccessibilityService. This would more closely mirror the uiautomatorviewer functionality, giving you a subset of what you see in Hierarchy View. This also requires a double-opt-in by the user: the user must install your app and activate it in Settings in the accessibility area.
As far as I know, you couldn't access other apps if they do not explicity share that info with you by the use of Intents (or if you own these other apps).
So, based on this limitation, my bets are you can't access another app's View Tree by regular means. And if you chould, I think you shouldn't, as this is somehow "secret" to other apps, and you'd be registering information without permission. In fact, what hierarchyview uses is, for sure, some sort of trick that directly uses internal private libraries of Android. Like taking a screenshot, that you can't do with the "default" implementation, but using these kind of testing tools.
That being said, check this answer, where it shows how to get the current app in foreground. From here, getting the View tree should be impossible, but as long as you could call getWindow() on that app's current activity, this could be done.
I am trying to create a benchmarking app that launches a few apps and measures the load time. Starting a timer and launching an app (via intents) is the easy part. And, if I have source to the child app, I can either have it record the time and pass that back, or I can just have it kill itself completely at some point. But, how do I know when stock apps have finished loading? Or, how can I make them close automatically so that mine is brought to the foreground again to stop the timer? I know the source for stock apps is public, but I don't think it's practical for me to try to modify it. Or is it? I can't tie my benchmarking app to a specific version of Android.
Specifically, I'm interested in measuring load times for the browser, youtube, and mail.
I've looked at using the ActivityManager to get info about running apps, but I think in that case I would have to poll in the background, and I've read that ActivityManager info is not necessarily always up-to-date, anyway.
Any suggestions would be very much appreciated.
I decided to just modify the source and build a version of my app for each version of Android/processor. I won't have to target each device specifically, just processor families (Atom/armV7/etc.)
Getting and compiling Android source is easy
Building a custom version of a stock AOSP app is also not that bad
From there, it's just a matter of using intents to invoke activities and pass information.
I want to add some functionality to existing (closed-source) applications on Android. For example: adding an item in the context-menu.
Is this possible? My guess is to hack my way into the Dalvik VM, but I can't find any information about it.
Is this possible?
Generally, no. If the "existing (closed-source) applications" have an API that they publish and document, you are welcome to use such an API. Or, if the "existing (closed-source) applications" are leveraging so-called implicit Intent actions, like ACTION_SEND, you can simply support those interfaces.
For example, many applications have some sort of "share" menu item or button, which brings up a list of applications capable of sharing the content the original app wishes to share. This is accomplished via ACTION_SEND, and if you create an activity set up to respond properly to ACTION_SEND requests, your activity can appear in this list automatically, no hacking required.
My guess is to hack my way into the Dalvik VM
Fortunately, that will not work. You cannot "hack [your] way into the Dalvik VM" running in another process.
Generally, I can say that you can. You should find the application, disassemble (dedex) it, make changes and build it once again. You can look at the different tutorials how do this.
I am developing an application that should be extendable
I want the user to install the base app and then extend it by installing extension packs (different APKs) or plug-ins (like go launcher and theme-packs or add-on widgets)
The only thing I could find is using library project to share the code but that doesn't fit my needs. Can someone explain how its done?
[edit]
To be more specific, here is what I want to do:
I have a set of animated scenes, effects and transitions
animated scene is a combination of code and resources
The user can select the 1st scene, 2nd scene etc..
I wish to be able to add more scenes but I don't want to include them all in one APK
I want to let the user download scenes of his choice.
To build this type of interaction, ContentProvider will be your friend. There are two options I can think of to build this type of system, depending on which direction you would like information to flow.
Option 1: Single ContentProvider in main application
Define a ContentProvider in your main application, which creates an external interface for other applications to read/write data to a common location. This provider maintains access to the scene data files/database your application needs.
Each subsequent plugin application accesses the main ContentProvider (and also warns the user if they run a plugin but haven't installed the main app yet) and installs its specific content by writing it to the ContentProvider. In this way, each plugin is designed to act as an "installer", meaning the user has to download and run the plugin from Market to install the scene content.
Option 2: Each "Plugin" application has its own ContentProvider
This option is the reverse of the above. Define a ContentProvider with a consistent interface in each plugin application and have a method from the main application that scans the system for new plugins (this can be done via PackageManager) and reads the data from each provider into its main local store.
The difference here is that the user won't have to run each plugin package, because the main application will take care of getting the data. However, there's more complexity in defining multiple providers. For instance, you have to make sure that, even if each provider has the same basic interface, they cannot have a single common authority, so you will have to scan the system for package names like your own and resolve the providers based on that information.
Editorial
Having said that, I feel I should mention that I don't believe this is a good method of providing content to your users. My personal feeling on the subject is this method pollutes the user's devices with application icons that do them no good, and it's difficult to hide that kind of thing on the mobile device. A simpler, and much cleaner approach to this would be to store your "add-on" content on a server (AWS services like S3 and SimpleDB are practically free) and use a service like Google's In-App Billing to let your users purchase the new content and download it directly into the single application rather than having them go back to Market and purchase more apps.
Hope that Helps!
I have a set of animated scenes, effects and transitions animated scene is a combination of code and resources The user can select the 1st scene, 2nd scene etc..
If the "animated scenes" are activities. your add-on APKs simply publish their own sets of activities, and you use PackageManager to determine which of your plugins are installed and how to use them.