Help making android application into service - Android Software Development

Hey guys, I'm fairly new to android applications. I am specifically working on an android application that runs for the Notion Ink Adam. A guy by the name of Mr.Guy actually wrote the app nearly perfectly and provided the source to me but there is a small issue I want to work out, hopefully with some help.
Basically the app runs from a search button long press, runs a native linux command (which toggles the backlight on and off) and closes.
The problem with the current application is that if you have somethings open in a current window they are closed by this application running. An example is opening the app drawer on the homescreen. Running the application closes the app drawer. In some cases th interruption makes a greater difference like when viewing media.
Anyway heres the source, ftp://eto.homeip.net/Shared/NotionInkHacks/PQiToggle.zip
I think I need the application to run a service instead of an activity but this didn't seem to matter. I'm pritty sure I need it to not call a UI and just run the service.
An ideal fix for this is to skip the application and just rely on keycodes run from init.rc but trying to do this I had zero success. I'm not sure if the version of init in my rom supports keycodes.
If you could help me either with making it a service or allowing a native linux command run from keycodes I would greatly appreciate it. Thanks!!!

You can call a service directly from a broadcast receiver which can listen for the "on search long press" intent
http://developer.android.com/guide/topics/fundamentals.html#ActivatingComponents
http://developer.android.com/reference/android/content/BroadcastReceiver.html

Related

Shortcut to Execute commands on Computer

There are all of these app's out there that allow you to control your computer from your phone (using VNC and others). This is all well and good....but there are no shortcuts to do anything on these apps. Whatever you are trying to do on your computer takes way too many screens/clicks to be truly efficient by using your phone. You most certainly are able to do it with your phone.....but hell...it was way more complicated than it had to be.
**DOES BELOW APP EXIST?**
I would LOVE to just touch a shortcut on my home screen that would send a couple of keystrokes to my computer. Or telling my computer to open a particular program from a shortcut created on my android phones Home screen. This would be amazing. I could tell my computer to run whatever task from my phone QUICKLY...without having to jump hoops through screenshots/mouseclicks/keyboard on VNC app's......
Using this, you would no longer need all these separate video/music player control apps...you could just wire hotkeys/scripts to be run to control ANYTHING. I could send a keystroke to minimize/maximize a window....pause iTunes....Give a song 3 star rating....open a particular site...
I'm just trying to turn my phone into a much better remote for my computer.....all current apps seem to fail horribly.
Hi,
I was looking for the same thing and came a cross a neat application to run on computer, AutoHotKey ( http://www.autohotkey.com/ ). Then I use MultiRemote to send keystrokes (like a hotkey, CTRL+P), programmed as one button in that program. Then on the computer side I have a script that knows what to do when that button is pushed Really powerful application with tons of features to program in the scripts...
BR
jmelhus

Develop an app to block launch of other apps

This is some hobby project i want to accomplish with, i have decent experience in programming java. But after quite a lot searching around and asking professors and anyone with experience in android development i got no clear vision of how this is accomplishable. The thing is, i want to develop an application that runs for a given amount of time(there´s a timer the user sets), during this given time certain applications will be blocked(or rather killed, or intents changed so they won´t even start to run). This selection will be done from a list given of third party applications installed.
As mentioned, ive searched everywhere i can, and the only leads i could ever find was the following:
1. Have continous check which kills the given application if it detects the specific applications running and will kill it. Downfall of this will be cpu-usage, optimalization and battery use. And also the device has to be rooted.
2. Have an alternative launcher, somehow this should help me a bit on the way to accomplish my goal. But here i sit thinking: Will i need to develop my own launcher to be able to succeed?
Nothing pointed me in any direction whether there are some native methods or similar in the android that perform similar tasks and how to implement it at all. Those who are saying there are plenty of applications our there similarly: No, they give you choices like block apps with a password and similar which is not what i´m after. I need some application that blocks it for the given time it´s set to(even though it is possible to go on your own in task manager and kill this application i want to develop, but that is out of the scope for now). This is to increase productivity without reaching for your cellphone all the time(yes, it might sound silly, but i´m quite sure it will help.
Any help is greatly appreciated as i´ve researched for over a month without any success.
Bring up your activity no matter which app starts. Make it a transparent activity and kill it as soon as it starts.

ExtensibilityApp class in WP 8.1 Silverlight

Hi all,
If you've read the text that USED to exist here before, scratch that. Big Thanks to @Sunius1 for clarifying what I thought was a win. Due to this, I DID find something interesting in regards to the ExtensibilityApp class (Windows.Phone.System.LockscreenExtensibility.ExtensibilityApp). I happened to also find a hidden capability "ID_CAP_SHELL_DEVICE_LOCK_UI_API" (Seems to be a locked CAP because it only works on Emulator. I get a deployment error on my if I try including this capability). I suspected that these two worked together, but I wanted to make sure of this.
Before we get started, read through the documentation from this site: http://msdn.microsoft.com/en-us/lib...lockscreenextensibility.extensibilityapp.aspx.
We have the following methods:
BeginUnlock
EndUnlock
GetLockPinpadHeight
IsLockScreenApplicationRegistered
IsSystemOverlayApplicationRegistered
RaiseToastNotifications
RegisterLockScreenApplication
RegisterSystemOverlayApplication
UnregisterLockScreenApplication
UnregisterSystemOverlayApplication
EDIT: After the release of the Live Lock Screen app, my speculations about the ID_SHELL_CAP_DEVICE_UI_API capability and the ExtensibilityApp object were correct. Thanks to @jessenic for finding out a good bit of info on this with me.
It seems that in order to get this working, we have to add an Extension to the WMAppManifest.xml
<Extension ExtensionName="LockScreen_Application" ConsumerID="XXXXX" TaskID="_default" ExtraFile="Extensions\\LockAppExtension.xml" />
In the LockAppExtension.xml:
<?xml version="1.0"?>
<x:Extension xmlns:x="urn:LockApp">
<AppID>AppNameForLockScreen</AppID>
</x:Extension>
As usual, Microsoft doesn't really give us much in terms of documentation.. Probably because it isn't meant to be used by the normal developer Confirmed: For now we have to actually ask for permission in order to use the cap. As to whether we'll get that granted? Who knows....
All of these methods have no parameters at all, but I can almost guarantee this has to do with having an application that can control the lock screen.
This thread will be for efforts in breaking this open and seeing whether we can create lockscreen applications..
Homebrew Lockscreen Apps:
Lockscreen App by @-W_O_L_F-
There are actually two Windows.winmd files in Windows Phone SDK, one for Silverlight 8.1 apps and one for Jupiter 8.1 phone apps (located in C:\Program Files (x86)\Windows Phone Silverlight Kits\8.1\ and C:\Program Files (x86)\Windows Phone Kits\8.1\). There's only one the phone. And some APIs support only one app type (it's phone limitation it seems: faking .winmd file results in Platform::InvalidOperationException, saying you cannot use that API from this app type). That explains why the one on the phone has more APIs available than either of for single app type.
As for LockscreenExtensibility - it's documented, just not available for Jupiter apps:
http://msdn.microsoft.com/en-us/lib...ows.phone.system.lockscreenextensibility.aspx
Sunius1 said:
There are actually two Windows.winmd files in Windows Phone SDK, one for Silverlight 8.1 apps and one for Jupiter 8.1 phone apps (located in C:\Program Files (x86)\Windows Phone Silverlight Kits\8.1\ and C:\Program Files (x86)\Windows Phone Kits\8.1\). There's only one the phone. And some APIs support only one app type (it's phone limitation it seems: faking .winmd file results in Platform::InvalidOperationException, saying you cannot use that API from this app type). That explains why the one on the phone has more APIs available than either of for single app type.
As for LockscreenExtensibility - it's documented, just not available for Jupiter apps:
http://msdn.microsoft.com/en-us/lib...ows.phone.system.lockscreenextensibility.aspx
Click to expand...
Click to collapse
Well that is very good to know! Thanks for the clarification. The best part is that I was actually able to compile without receiving an error (somehow).
I found something that may be of use in order to get the LockscreenExtensibility working (I just tried on a Silverlight 8.1 app and got access denied).
<Capability Name= "ID_CAP_SHELL_DEVICE_LOCK_UI_API"/> <----. Can't be used OOTB
EDIT: I just tested this in the Emulator and it really IS the capability that the LockscreenExtensibility needs in order for it to work.
snickler said:
I found something that may be of use in order to get the LockscreenExtensibility working (I just tried on a Silverlight 8.1 app and got access denied).
<Capability Name= "ID_CAP_SHELL_DEVICE_LOCK_UI_API"/> <----. Can't be used OOTB
EDIT: I just tested this in the Emulator and it really IS the capability that the LockscreenExtensibility needs in order for it to work.
Click to expand...
Click to collapse
I assume this is the thing Rudy Hyun used to create the lockscreen app at Build?
TheInterframe said:
I assume this is the thing Rudy Hyun used to create the lockscreen app at Build?
Click to expand...
Click to collapse
I speculate that this is what he's using. I bet there's more going on that we have yet to figure out. It also could be that the base class EXISTS, but the full implementation isn't available yet. Who knows.
snickler said:
I speculate that this is what he's using. I bet there's more going on that we have yet to figure out. It also could be that the base class EXISTS, but the full implementation isn't available yet. Who knows.
Click to expand...
Click to collapse
Ah, Yes that makes sense. I wonder if there are any other "half-baked" API's in the SDK?
Edit: I Know it sounds stupid but honestly I think we should have a thread dedicated to finding odd API's (Just found one: Windows.Phone.System.SystemProtection, nothing terribly useful though)
TheInterframe said:
Ah, Yes that makes sense. I wonder if there are any other "half-baked" API's in the SDK?
Edit: I Know it sounds stupid but honestly I think we should have a thread dedicated to finding odd API's (Just found one: Windows.Phone.System.SystemProtection, nothing terribly useful though)
Click to expand...
Click to collapse
there are also some hidden APIs in the current SDK for 3D Touch-enabled Apps!
From WP Central:
Some of the features include APIs for gestures, side interactions and even heat maps.
Crazy stuff.
Believe it or not, some of these APIs for developers are in the current SDK, they're just not visible. What this mean though is developers will have access to this 3D Touch technology for their apps. It also means that Microsoft will have a small batch of third-party apps supporting this 3D Touch technology on launch day.
Click to expand...
Click to collapse
source: http://www.wpcentral.com/microsofts-next-flagship-windows-phone-november-3d-touch
Yea, even though those 3D touch APIs may be available, they're not particularly useful, as they require special hardware to work.
Sunius1 said:
Yea, even though those 3D touch APIs may be available, they're not particularly useful, as they require special hardware to work.
Click to expand...
Click to collapse
That is true. Sort of of a side question though, has anyone made a OEM account and looked over the API documentation there? There maybe some useful things we could learn about WP and maybe further a jailbreak for all WP devices....
TheInterframe said:
That is true. Sort of of a side question though, has anyone made a OEM account and looked over the API documentation there? There maybe some useful things we could learn about WP and maybe further a jailbreak for all WP devices....
Click to expand...
Click to collapse
API isn't much useful as long as you cant really use most of functions due to policies.
ultrashot said:
API isn't much useful as long as you cant really use most of functions due to policies.
Click to expand...
Click to collapse
Ah, Yes that makes sense....
http://www.wpcentral.com/joe-belfiore-announces-new-updates-sheds-details-lock-screen-app
Sounds like there will be a dev preview update to enable lockscreen functionality quite soon. Joe also mentioned keeping the lock screen in memory. So 512 MB devices won't get the functionality soon....
Good stuff. Another question: can apps show the action center? Because I want code an app to show notifications on lockscreen. Thanks
Marocco2 said:
Good stuff. Another question: can apps show the action center? Because I want code an app to show notifications on lockscreen. Thanks
Click to expand...
Click to collapse
something to force the volume/music control on the lock screen to automatically open would be really useful as well
Updated first post with some more data since the Live Lockscreen App debuted yesterday. There's more I didn't get into, but I want others to dig in and find out
I suppose we can only speculate how it works at this point, but if I had to guess, it goes like this:
1. You have 2 projects in your LockScreenApp solution, one for the application to register the lockscreen, and the second one for the actual lock screen application.
2. The former would use ExtensibilityApp APIs to register the the second one, coupled with the manifests so it's all "valid".
3. The second application is just a another app that is able to process input and draw whatever it wants on the screen. That would explain why there's a delay at it starting when you press lock screen button while the phone is sleeping (probably it's a time for .NET to startup? Direct3D app should be able to start much faster).
Although this is only speculation, I think this makes sense, because that's how background tasks work on Windows, at least. I wonder though, why Microsoft is not releasing the APIs to be used in public - are they afraid somebody will make a lockscreen application that will drain the battery fast or something?
Sunius1 said:
I suppose we can only speculate how it works at this point, but if I had to guess, it goes like this:
1. You have 2 projects in your LockScreenApp solution, one for the application to register the lockscreen, and the second one for the actual lock screen application.
2. The former would use ExtensibilityApp APIs to register the the second one, coupled with the manifests so it's all "valid".
3. The second application is just a another app that is able to process input and draw whatever it wants on the screen. That would explain why there's a delay at it starting when you press lock screen button while the phone is sleeping (probably it's a time for .NET to startup? Direct3D app should be able to start much faster).
Although this is only speculation, I think this makes sense, because that's how background tasks work on Windows, at least. I wonder though, why Microsoft is not releasing the APIs to be used in public - are they afraid somebody will make a lockscreen application that will drain the battery fast or something?
Click to expand...
Click to collapse
I don't think its that but most likely the fact that the API is un-optimized, some of the facts you stated (i.e. Slow start up, documentation is lacking) etc... The fact the OS needs to be updated to show a section telling the user what lock screen app has taken over (since the setting page doesn't now)
Edit: Remember what Joe said about keeping the lockscreen in memory and 512MB devices might not be supported for that reason? Yeah seems like they aren't doing that since you can see the resume time for the lo screen is wayyy to much
Sunius1 said:
I suppose we can only speculate how it works at this point, but if I had to guess, it goes like this:
1. You have 2 projects in your LockScreenApp solution, one for the application to register the lockscreen, and the second one for the actual lock screen application.
2. The former would use ExtensibilityApp APIs to register the the second one, coupled with the manifests so it's all "valid".
3. The second application is just a another app that is able to process input and draw whatever it wants on the screen. That would explain why there's a delay at it starting when you press lock screen button while the phone is sleeping (probably it's a time for .NET to startup? Direct3D app should be able to start much faster).
Although this is only speculation, I think this makes sense, because that's how background tasks work on Windows, at least. I wonder though, why Microsoft is not releasing the APIs to be used in public - are they afraid somebody will make a lockscreen application that will drain the battery fast or something?
Click to expand...
Click to collapse
You are correct. Two projects: One is the settings page, which is the main entrypoint of the app when it's opened from the start menu and the second one is the actual lockscreen app.
The settings page uses the ExtensibilityApp APIs to register the second one as a lock screen application. That second application is another 8.1 Silverlight app that uses a LockScreen_Bridge WinRT component that has native access to read what is shown on the lockscreen from the WP Settings item.
It then uses some storyboards to make it do different things as you're swiping up and down on the LayoutRoot grid. It does use a timer so that's where that little lag comes from.
The only background stuff it's doing is latching on to system events ("Start button being touched for example").
I can see where MS would be protective of this. They DID say that they would be releasing a public version of the API at some point. I'm hoping it's not one of the situations that leaves it public only when they've approved you to be able to use it.
It does suck that it's restricted to 8.1 Silverlight though. I could see some Music Apps wanting to take advantage of the lockscreen like this.
snickler said:
You are correct. Two projects: One is the settings page, which is the main entrypoint of the app when it's opened from the start menu and the second one is the actual lockscreen app.
The settings page uses the ExtensibilityApp APIs to register the second one as a lock screen application. That second application is another 8.1 Silverlight app that uses a LockScreen_Bridge WinRT component that has native access to read what is shown on the lockscreen from the WP Settings item.
It then uses some storyboards to make it do different things as you're swiping up and down on the LayoutRoot grid. It does use a timer so that's where that little lag comes from.
The only background stuff it's doing is latching on to system events ("Start button being touched for example").
I can see where MS would be protective of this. They DID say that they would be releasing a public version of the API at some point. I'm hoping it's not one of the situations that leaves it public only when they've approved you to be able to use it.
It does suck that it's restricted to 8.1 Silverlight though. I could see some Music Apps wanting to take advantage of the lockscreen like this.
Click to expand...
Click to collapse
Quite interesting...!
The API in itself is quite powerful, custom lockscreens with weather animations are possible! http://wmpoweruser.com/wp8-1-live-l...amazing-lock-screen-weather-animations-video/

Writing Global Overlay Help

So the end goal in this project is to view an RTMP stream and interact with the server at the same time.
This is a little hard, because obviously VLC or Mx Player or whatever I'm viewing the RTMP stream with doesn't know how to communicate with the custom server. So I'm trying to make an overlay that will sit on top of the player which has buttons, the buttons can then communicate with the server which will alter the stream and you'll see the result streamed to the player. This is sort of like an interactive HUD if you will.
Problem is that it's difficult to make an overlay which will take actions if they're clicked, but can also pass those actions to the background app (in this case the player) if it opts not to process them. Right now my app creates a service and the service catches the input and displays whatever. This WORKS, but the problem is no matter what I return from "onTouchEvent(MotionEvent)" in the view of the service (true or false) the home screen is frozen. It catches the press but it won't pass it on, even if the function returns "false" - to say it's not handled.
I'm not sure if I'm not passing the touch event on correctly, or is this not even possible? I read somewhere that it's not possible for app A to provide input to app B, but I'm not sure if that is correct (frankly I don't believe it). Basically I want to handle some presses in the overlay and allow some others to go to the active app beneath it.
Does anybody have any input for making this work as expected? I'm creating a view to pass to the window manager with the following flags:
Code:
LayoutParams params = new LayoutParams(LayoutParams.TYPE_SYSTEM_ALERT,
LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
I've tried playing with the flags but to no avail, I cannot get the touches to go through, even if all the onTouchEvent(MotionEvent) function does is return false.
Anybody have any ideas?
I'd be open to alternative implementation ideas too, the point is I need to basically have two communication channels open, one is a player (ie. VLC) for viewing the RTMP stream, which likely would not change, the other would be the command stream, which will control said server, which I am open to change. I considered trying to use the accelerometer in the service instead of an overlay, but I think that would create a bad proof of concept UI (because there's some latency in the video stream), any alternative ways to communicate with the server would be up for discussion! Maybe I can plug an IO device into the USB port or something, like a keyboard? Extra buttons could be of use. It's only a POC, so some clunkyness IS okay.
EDIT:
As you can see above, I used an alert type instead of an overlay type, I guess this is because overlays won't accept focus after a certain Android version number. I'm using 4.0.4 ICS.

Automatically reopen android/ios app after x minutes

We're building an app that will be installed on smartphones and displayed on a desk. The user need to be able to close the app and use the device, but when he does not use the device the app should move to the front automatically after X minutes.
Here is the catch: we need to support new devices for the coming 3 years and the user should not be able to close/kill the process.
Android: We found that we could use the permission BIND_DEVICE_ADMIN to make the process unkillable. However it will be deprecated soon and we have no idea how long it will remain functional.
iOS: We found no solution
Does anybody have a workaround/solution or does somebody know how much longer they will support the BIND_DEVICE_ADMIN permission?
I know it seems like something fishy, but it's actually intended for distribution internally via our company MDM and it makes sense in the context we are using it for.

Categories

Resources