Android - Globally assign function to gamepad key combination - java

I'd like to set up an Android TV box (Lollipop 5.1.1) to be able to function just with an Old PlayStation controller. Unfortunately it doesn't have a dedicated home button. I'd like a solution which makes the device return to home screen on a key combination (like L3+R3)
I've never made a standalone Android App or Service before but I am more than willing to learn it with some kind help :)
May a service with game controller event listener work?

Related

How to perform swipe down programmatically in android

Hi I want to refresh a application by swiping down programmatically (for example Facebook app) from a service running in the background. Is it possible?
Not generally. Apps can't send touch events to one another. It can be done if its your app in the foreground receiving the gesture (although then there's easier ways to do this than faking a gesture), or it can maybe be done if you're an accessibility service (but they won't allow you on Google Play if you're using accessibility for something like this).
If its a personal app, you can checkout AccessibilityService and dispatchGesture() for a possible solution.

Strategy for transparent Android app that allows 3rd party app behind it to update

I have an Android app that is transparent that monitors for an event and then displays a message and toggles the background between transparent and a translucent red. The app itself is working exactly as I was hoping. The problem is that only the top most app (my app) is active and updating the view. The app displays over a 3rd party app that runs a live video stream. I want the live video stream app to continue to update while my transparent app is on top. Since I have no control over the other app and it doesn't support multi-window approach, I am looking for a different approach or work around to accomplish the same thing.
I have read of people trying to use a system popup based on a service. Does anyone have experience trying to solve a similar problem and found a good approach for designing the app or a work around?
Try to google about Activity lifecycle. When another app comes as the top application (let's say your transparent app) the last playing application goes to onPause until the user bring the last app back to the top again.
The short answer is: what you want is not possible.
any question?

Keep android app in foreground unless in in settings

I have an app for a customer (refer to it as "their" app). When "their" app is open they do not want users of the device to use any other apps.
The only way they want to get round this, is if i create a login page within the app, and from there you can go to the android settings page. If the android settings are accessed, then the user should be able to go anywhere they want, until "their" app is in the foreground again, then the device should be locked into using just that app.
If this makes any difference, "their" app is a cordova app. I dont think it will, but thought i would mention it anyway. Needs to work in android 5.0
Is this possible at all? What would i need to implement for this? A service and timer?
UPDATE
It is a tablet, so it will never ring.
If the user presses the Home button, nothing should happen as the app should stay in the foreground

Embed android application into other android application (Overlay + Events)

I was wondering if it's possible in android to embed an application into in another application. In this way you can have control of the embed application and you can add some other functionalities thanks to the parent application.
EDIT :
To be more accurate, I would like to have an application (parent application ) which can overlay the content of another application (embed application) without losing control of the parent application.
Thank you,
You can not specifically embed one app in another. And unless there is a specific inter-application API you have available to you, you cannot control the one app from your parent app either.
However if you just want to be able to view your parent app as some kind of overlay over another app, there are techniques that you might find useful.
It is possible to create an overlay view that can be seen when other apps are in the foreground. This is used by some chat clients, video playback, and task launchers. You can find some info on this method by looking at my answer here:
Background app to listen to Drag gestures
It is important to realise that in "the old days", a technique like this could be used to steal data from someone's phone. It was possible to receive taps & drags, and then pass them on to the other app.
This was a security hole, and has been fixed. So these days, you can choose if your overlay view should receive the taps or not i.e. if it is interactive, or just shows info.
Because of this, you will not want to cover up any of the "embedded" app with your own UI.
It is not possible any more to receive taps in your app, and pass them through to the other app.
This is not possible in general. The only thing that comes close is "embedding" an app widget in a home screen.

First android app for iOS developer

i am iOS app developer. Now when i created an app on iOS i want to do the same on android. With java i was familiar just now need some time to remember.
i was looking at some tutorial how to do one or other things. But what i can't find is the basics how everything works. How classes is interacting with each other.
For example i want to create registration window with few buttons and alerts.
I want registration window to be called just once when app is installed and just that.
Should i create new java class and few layouts, one for View with buttons and other for Alerts ?
Or should i create other class for alerts if i need them in other flow of my app ?
And how i should call that window with registration from my main class, which is
extends Activity
Also if there are some developers who came this road from objective-c (iOS) to java (android). It would be nice for some share experience how they did that.
Thank you for any help :)
Very few of the concepts in iOS and Android are similar. On Android you have Activites, Intendts the Manifest. When you design your layout it should be resolution independent. You have a search, back and a menu button and variable hardware. All of this has no equivalent in iOS.
That said, I think you just have to read the basic concepts and the getting started guide no matter if you come from iOS or never have done mobile development before.
EDIT
To answer your concrete question. Take a look at the lifecycle of an Activity and Preferences. With this, you could do some action on the first start of your main Activity and store some flag in the preferences when it's done. On the next start you just test that preference and skip the logic.
You can create one activity (.java file) and one layout(.xml file with buttons and input boxes) , alerts could be toast notifications:
http://developer.android.com/guide/topics/ui/notifiers/toasts.html
All you require for this is a activity and a layout xml for that activity, this activity will be your main ie the entry point to your application, in that activity oncreate method you can check if it is registered or not by setting a flag or something which will direct to the next activity if its registered.
GOOD LUCK...
Just like your nibs in iPhone you create xml layouts in Android. And for view controllers here you make activity. One important thing is AndroidManifest.xml file, it contains all information of your app (like plist) plus all the activity information(Intent type and launcher methods).

Categories