Include a service in a SDK/library - java

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.

Related

How to update Android OS on the device through an App

Is there any way to update the Android OS through an App(Using Android API or any other API/) after checking if a newer Android version is available in the market/Playstore
The Use Case required to be supported here is as follows:
The App starts and checks the version of the installed Android OS
It then finds the version of available Android OS in the
Playstore/other repository for that device
Then it compares the two version and if the available version is
newer, then it installs the new Android version on the device
How can it be implemented , especially the third point ? I do not want to root the device for that, so if there is any way to achieve this, please help ....
There is no API. If your device has an update feature built in (most do), you can decompile the update service and see how it works. If your device does not have an update feature, then you can look at custom ROMs for your device. Once you get ahold of a ROM or an update.zip you want to use, the process cannot be done automatically. The updating takes place in the system recovery mode where the user will have to select the .zip to update. However, if you can decompile and figure out how your manufacturer's update service works, maybe you can pull off an automated process.
There aren't any tutorials or documentation for this, as it is 100% dependent on phone model/OS. You can probably find a flashable ROM for your device, however, but the process is rarely automated. Actually, take a look at ROM Manager in this case, it is a somewhat automated upgrade app. I tried it before and it bricked my phone. Good luck
You would need to know where to ask if there is a newer version. And then is there an upgrade available for that particular device. At that point you could broadcast a request to update. Does not the device know when an update is available?
For updating your android version you would need
Custom Android on you device.(Some more info)
Rooted device.why need rooting?
Now for installing we would need to flash ROM.You would also need to have check for version of the OS available, which depend upon your logic .Generally Samsung ,Sony they use custom android and the updates are pushed over app center( or something like that,not much knowledge) in your case it may be any cloud service or server to check version for your custom android.
When we have a new version, after user accepts to upgrade, a new img file would be downloaded to your device which would be used to upgrade the OS.Please note you would also need a recovery backup method too.There are some Commands that can be used to extract and download the OS through your code.
I haven't implemented it yet but this is the procedure i could find.
I hope this would help others.
UPDATE
I have got some new information about how can we initiate the update through code. the Link and there's this another link that can be great help.
In both the examples they are using SystemRcovery class with intallerPackage API.

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.

How can I save my Android application so that the end-user can execute it without the Android SDK

I have recently started programming for the Android platform. I have a simple application which I would like to email to someone so that they can execute the application and check how it works.
I am currently using the Emulator in the Android SDK to execute my application but the person who I am emailing it to does not have Android SDK and it would be a mission to send the whole project folder.
Is there any way that I can send just one file such as an .exe or something that would allow the recipient to execute the application to see how it works.
Thanks so much for your help in advance guys
The "exe" for android is called apk. I suggest you to look at this question. You'll need to build the apk and sign it in order to be able to run it.
If you just want to send it to a user for testing purposes, you can enable the setting in the target android device to allow "unknown sources" (I don't know the proper english name, as I don't have an english android here at the moment). You can find this in the app settings.
In your development environment look for the apk file created by eclipse. Then connect your smartphone to the pc and copy the apk over. Start up a file manager and click on the apk and it will install just like any other app.
If you want to deploy it properly, you have to sign it and probably follow the procedures from google. Since I don't have a fully deployable app yet, I can't say what the procedures is for that, but the google site is very helpfull on all aspects about android programming.
Check the "bin" folder in your project path. There you will have a .apk that you can share with your clients.
If they execute it in an Android mobile phone the application will be installed.

Reinstall application apk programmatically without downloading

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.

Can I build android executable right from my android application

How do I build a android executable from my android application? I am building an application where it would send some application data to another device. If the receiver is using my application, there is no problem. But if the receiver is not using my application or not aware of it, the application data means nothing to him, unless the sender informs him about it.
I wish to build a executable, right from my android application, which will run on receiver end. Receiver may not modify it but can run it easily.
Example of such use:
Video recorder or converter application which convert/record video on a custom format and play it. Now the sender wants to send that video to his friend. Unless he have installed such video, he can't access it. However if it is possible for the sender to create some executable to embed that video, which can run on any android device it would be great.
Even if it were possible, it is definitely not practical to compile an application on an Android device. Why not make the compiled application available in the Android market and/or your own URL, and then get the receiver to download and install it?
Like Elevine said, you should send a URL to App in Market instead of sending an app.
If google/Android evev allow sending app directly, Spammers, virus writers will love the "features". It is as bad as ActiveX plugin date of IE5,6.
BTW, I thought about this kind of approach before. One can have all the prebuilt jar, dex files ready and just want to zip them together with new data as resources, signed it with the right key. It is possible to do it in the phone. But you really don't want to do put your signing key in anyone's phone.
It is much better/simpler to just submit the needed data to a server in the cloud have sign the package there.

Categories

Resources