Android: setOnClickPendingIntent in a statusbar notification on Gingerbread - android

I made an app that had two buttons in a custom notification whenever it was displayed. I set up an OnClickPendinIntent for each of the buttons, so that they could perform 2 different actions based on which button was pressed. My app worked flawlessly on an AOSP Froyo ROM, but once I upgraded my phone to Gingerbread, the buttons are no longer clickable. Basically, no matter where you press on the notification, it only registers as the notification being clicked. The buttons are being completely ignored.
Is this something that just needs to be coded differently in Gingerbread? Or did the functionality get removed for some reason? And is there any solution to re-enable this functionality?
Thanks.

Or did the functionality get removed for some reason?
The functionality was never there in the first place. You cannot put interactive elements on a Notification's RemoteViews. Some devices would support this, but it's not part of the platform.

Related

How to show an image overlay only for specific applications?

I want to create a image overlay, behaving like the "chat head service" of the Facebook app, but which will show or hide depending on the application currently in the foreground. For example, if the app currently in the foreground is Gmail or Hangouts, the image overlay should be visible, else it should be gone.
I had no problem with creating and running the service which shows the overlay, with the drag-and-drop feature and all. I'm stuck with how the service can show or hide the overlay, in other terms how it can precisely detect foreground change.
I have read many posts suggesting ActivityManager.getRunningTasks(), but this feature is deprecated since Lollipop, and does not work correctly since.
Some other suggestions are about using Accessibility Service, but I do not want to use it, mainly because my app has nothing to do with accessibility.
The exact behavior that I want to reproduce is the one implemented in the "Popemoji" app. It may not be a brilliant design, but it works consistently on Android 4+, and it does not require Accessibility permissions.
Thanks for your time,

How can I use startLockTask() method for versions of Android Lower than L

I was using startLockTask() in a program but found out it could only be used for Android L. However I want my application to function in versions lower then 5.
Is there any way I can gain similar functionality?
Functionally, no. The point of screen pinning is to prevent the user from leaving your app. The user can't see or click on notifications, or use the home button to leave.
Visually, you can set the app to full screen,, and/or hide notification bar. You can also hide the soft keys on devices that don't have hardware buttons. However, people can always bring it back up.
EDIT: You can also disable the back button.

Disable Home Button or system bar on tablet

I'm working on an existing Android application for medical purposes.
The back button and home button should be disabled.
With the existing code, the back button is disabled.
For disabling the home button they used onAttachedWindow with LayoutParams TYPE KEYGUARD,
but this security hole is fixed since 4.0.
I tried a lot of similar questions, but none worked out for me.
What is the way to get this done these days?
Also, hiding the status bar on tablet (where the home & back button live) would do the trick,
so any suggestions there are equally helpful!
Update: also, free third party apps that do the hiding trick are okay!
This sounds like a kiosk or dedicated use kinda thing, yes? You want your app to "own" the tablet and prevent other usage? I did this for an app whose sole purpose was to act as a remote control for a custom device. Basically I created two apps, a "custom launcher" app and the app that did the remote control. It's probably possible to integrate the two, but I wanted to support both dedicated and non-dedicated use. Note that I gave the launcher app a password-protected way to access settings so that I could recover the tablet at any time.
You can find a number of tutorials that will guide you through creating a custom launcher, just strip out all the stuff that makes it a generic launcher and replace it with an image button or similar that launches the actual app, or replace the launcher activity with your main app activity. Warning: I never figured out how to remove the launcher except by going into the settings.
As for hiding the system bar (notifications and status icons at the top of the screen), you'll want to use a full-screen theme like #android:style/Theme.NoTitleBar.Fullscreen.
As for hiding the home button I took this approach:
View main_layout = this.findViewById(android.R.id.content).getRootView();
main_layout.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
Unfortunately the STATUS_BAR_HIDDEN flag is deprecated now, but I think some of the other options would have the same effect. Regardless, the best you can achieve within Android's intended use is to temporarily hide the navigation buttons (home and back). A tap on the screen will bring them back.

Removing notificationbar for kiosk mode

I am trying to build an android app in kiosk-mode in Android 4.2.2 (Jelly Bean). What I have achieved till now is to make the application as full screen and also handled the home and back buttons. However, my problem is, I want to remove the status/notification bar. I don't want the user to access any other settings through it. I have tried out many ways including the usage of different flags available in android WindowManager for having a screen devoid of the notification bar. However, none were helpful for that.
I have read about apps like Surelock which serve this purpose. Therefore, at least I know that there is something which can be done, except rooting, to remove the notification bar.
Can anyone please help me on this?

How to dynamically add a lock-screen widget

Google Play Music app adds a special lock-screen widget dynamically when playing music (on Jelly Bean), and removes it after exit. This widget cannot be removed manually by dragging, and when I unlock my phone, it is always the top one besides other lock-screen widget.
How to implement this special dynamic lock-screen widget? I can only find documents about regular lock-screen widget, but not for this.
I was looking for the same thing and found out this is done by using the RemoteControlClient, check #CommonsWare answer here What is RemoteControlClient in Android 4.0?

Categories

Resources