[Q] Play/Stop buttons to Ongoing Notifications - Java for Android App Development

Hello Guys,
How can i add an ongoing notification with 2 or 3 buttons... play stop next !?
Something like this
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
...When i tap a button i want to do an url post.
android 4+
Thanks

Its actually very easy to just add an expandable button to the bottom of your notification (android 4.1+ only I believe):
Code:
Intent mIntent = new Intent();
mIntent.setClass(context, MyClass.class);
PendingIntent mPendingIntent = PendingIntent.getService(context, 0, mIntent, PendingIntent.FLAG_UPDATE_CURRENT);
mNotificationBuilder.addAction(R.drawable.icon, "Test", mPendingIntent);
This call will simply add a button at the bottom of the layout with a little icon called "icon" from your drawables, the text "Test" next to it, and when clicked on will take you to the class that you set as the pending intent.
you can add up to 3 of these (i believe, someone correct me if i'm wrong) per notification.
To get layouts that have buttons on the side (or anywhere other then just under the actual notification) is little trickier though. you'll have to create a layout and then use remote views to get the job done and I dont have an example for that! check out here at the bottom of the page though and it talks about using remote views a little bit. Just be careful with the layout that it will work for different screen sizes and devices!
as for an ongoing notification, here is what you want to call:
Code:
mNotificationBuilder.setOngoing(true)
its also a good idea to set priority for ongoing notifications in my opinion so that they appear where you want them to in the drawer.
Code:
mNotificationBuilder.setPriority(Notification.PRIORITY_MIN); // there are lots of options other then PRIORITY_MIN as well to check out
Hope that helps get you started!

@klinkdawg what you are describing are the action buttons which appear below the notification. In the Google Music app the play/stop buttons are embedded within a custom notification design. You can set a RemoveView with your layout with SetContent function:
http://developer.android.com/refere...er.html#setContent(android.widget.RemoteViews)
However all this good stuff is only available in API level 11+, and the notification with bigger content in API level 16+.

Related

mToday ( Profils 2 today) Free

I found browsing on the Internet a little program here is very interesting
Description: mToday is an application for you to switch between two today screen profiles to enable/disable pre-defined today plug-ins quickly and conveniently.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
​
link for more informations here
thanks Vicott Wong
nice catch bro, i like it
thanks
great find, thanks.
hmm, interesting, thanks.
Nice idea, but very very slow.
good but keep improving
This is a good idea but as mentioned slow, so keep improving.
If you want a quick second today, take the battery status today. Then you have two today screens. But this kill one today and go to the other today. This good to save memory. For me its good. In one I have all my things. And if I want IGO8 I take the other.
NEO130,
Could you please elaborate what is the "battery status today" that you use for mToday with minimal memory?
I try to do the same: one mToday profile with the applications I commonly use and the other mToday profile for iGO8. The profile with commonly used applications works OK but when the link of the empty profile for iGO8 is invoked it stuck my HTC Trinity such that it needs a hard reset. The succeeding boot yields the empty Today.
Not a convenient way to switch profiles, though...
Thank you,
Shkauf
Hi.
I posted this over at MobiSapienz but it may be easier to chat over here?
So I read:
"Added command line option to launch settings (-p0)"
When I do:
Run(SystemPath( "ProgramFiles" ) \ "Vicsoft\MToday\mToda y.exe","-p1")
It pops up the mToday Switcher and leaves it there.
Am I not doing the command line argument correctly. I did try "-1" but as I suspected that also popped up the switcher.
I am also assuming -p0 refers to mToday 1, and -p1 would refer to mToday 2.
I kind of wish there were a reg setting for "Current mToday Profile" for last switched profile.
Thanks...
(Integrating StatusTicker with mToday)
thank you lepsyfou
thats very helpful

[App] Push v0.01 (aka new Pocket Gforce)

Hi all on the last week some friends ask me to make some simple apps using the Accelerometer from HTC and other. I'm still up my neck whit work but some simple app's came true. So heres one...
Gforce Push v0.01
This one is really simple but me and my friends enjoy driving whit it all the time.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Atm all he does is...
First put your devise in landscape mode (it will return to normal in the end)
Prevents backlight Dim and Standby (it will return to normal in the end)
show Total (x/y) Gforce in the big Blue center label
show Total (x/y) Gforce in the bar on the right (scale can be selected on the options menu)
show direction of Gforce(or movement if you invert x/y in the options menu)
show update rate on the red label
show other debug stuff on the green label (x, y , angle and battery)
atm Auto Calibrate is not working reasonably well so don't use it.
How to use it....
I dint make a instaler so yoiu have to copy the files to your devise manually and the open
"Push" folder must be put in the device memory root!!!
To go to options just touch the label "Options"
to go back to main just touch the label "Main"
to manually calibrate click the right button on the Dpad
to close the app click the center button on the Dpad
Skins...
All image's can be change but for the moment don't use different sizes
To do list...
Make config file to save preferences and path for the "img" folder.
Put Auto Calibrate more reliable
Release v0.01
http://rjsmsampaio.googlepages.com/Pushv0.01.rar
Thats it for 3 days of work.
Plz do comment.
Hi Ikari, I have downloaded your application. I'll tell you my experience after I tested it on my HTC phone.
Maybe I didn't test it in the right way, the arrow didn't point to the right direction that the phone was moving or accelerating. Nice arrows though.

[Q] Auto-dismissing text popup

As stated in the subject, I'd like to implement in my project that little auto-dismissing text popup that sometimes appears when applying an action in certain apps.
It's a simple floating text with a dark rectangle as background positioned in the bottom part of the app that remains between activities/application switches and goes away automatically after X seconds.
Does anybody know how it's called?
It was called Toast.
You can easily custom a toast to have a interface like whatever you want, look Titanium Backup for example.
Default usage like below:
Code:
Toast.makeText(mContext, "Hello", Toast.LENGTH_LONG).show();
As a side note, the App-Msg(Crouton) library provides a good alternative to toasts : in that it is context-centric, the message will only be displayed on the activity/fragment it was generated from, whereas if the user quits your app while a toast is displayed, for example, the toast will be displayed on his launcher or on he app he switched to, which could be confusing.
Its usage is also very simple :
Code:
AppMsg.makeText(/*Activity*/, /*CharSequence*/, /*AppMsg.Style*/).show();
Maybe this library can be helpful on my app. I have a custom toast, which still displayed after I choose to leave the activity via a button. So with this library the toast dissapear when the activity goes to background? And also can customize the look of toast?
dancer_69 said:
Maybe this library can be helpful on my app. I have a custom toast, which still displayed after I choose to leave the activity via a button. So with this library the toast dissapear when the activity goes to background? And also can customize the look of toast?
Click to expand...
Click to collapse
Yeah exactly.
And yes, you can modify the appearance of the toast to a certain extent (background color, gravity and display length afaik) using the static methods already setup in the library, but nothing prevents you from forking the library and modifying it to suit your needs.
You can also choose to have a toast which will only be dismissed when the user clicks it.
There are 3 types of preset styles for the croutons (from left to right in the image below) :
AppMsg.STYLE_ALERT (red) AppMsg.STYLE_CONFIRM (yellow) AppMsg.STYLE_INFO (green)
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
But you can create your own using something like this :
Changing length & color :
Code:
AppMsg.Style style = new AppMsg.Style(AppMsg.LENGTH_SHORT, R.color.holo_blue); [COLOR="SeaGreen"]// the default length is [I]AppMsg.LENGTH_LONG[/COLOR][/I]
colors.xml :
Code:
<resources>
<color name="holo_blue">#33B5E5</color>
</resources>
Changing gravity :
Code:
appMsg.setLayoutGravity(Gravity.BOTTOM); [COLOR="SeaGreen"] // the crouton is displayed at the top by default[/COLOR]
Result in the thumbnail
Thanks to Evgeny Shishkin for his work on this library by the way.

[APP] Don't Pause - Automatically silence notifications while playing media in your c

Don't Pause!
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I was not sure where to put this, but I wanted to make my app available for your custom rom.
It requires no configuration. Just download "Don't Pause and click the start button to start the service. It runs in the background and whenever you start music, the app will put your phone into vibrate mode. After you stop the music, "Don't Pause" changes your phone back to normal volume. It is that simple, but there are a few options in the free version.
The paid version Unlocks quite a few upgrades that will automate the use of the service.
Help Translate Don't Pause
Change log:
Code:
Changes:
v3.2 -- Updated UI, fixed loud notification volume bug when stopping the service.
v3.0 -- Fixed the settings menu for people using Android 2.1-3.0. Lowered exit notification volume, Improved the look of the widget.
v2.8 -- gave control back to the user when the service is running but music is not playing, changed notification icon, added tablet mode into the free version, added compatibility for Android 2.1+
v2.4 -- Added preference screen for advertisements and notification otpion. Cleaned up unused code.
v2.3 -- Localization of some strings and widget fixes/mods.
v2.2 -- Added the 1x1 widget that many people requested
v2.1 -- Added 2x1 home screen widget and persistent notification for the status bar.
v2.0 -- Initial Public release
Don't Pause! on the Google Play Store
Don't Pause PRO! (Ad free) on the Google Play Store
Don't Pause! v3.0/ 4-05-14 - Google Drive
***DISCLAIMER - there is an interstitial ad when you click to stop the service in the free version. That is the only time you will see an ad. Did not want anyone to think I was trying to cover anything up.***​

[Q] Develop a pattern recognition app

I want to develop an app that can be trained to recognise certain characters. It's some sort of a word recognition app but for single characters. The problem with this is that i cannot find an appropriate input method even tough I've been struggling for two days to make it work using some sort of a GridLayout wich contains buttons. The problem with this method seems to be that i can't resize the buttons or remove the space between them. LinearLayout doesn't seem to be a good option either, since I can't swipe over the buttons and mark the letter.
THE ACTUAL PROBLEM:
I want to use an input similar to the picture i attached. That would be the letter A.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
.
The user will swipe over the matrix and leave a trail colored in blue. Then the matrix should be translated into the phone's memory to a binary matrix with 0 and 1 values.
RESTRICTIONS:
I want to tackle this problem programmatically.
The matrix will be 64x64
I use Android Studio.
---XML would be the easiest way to go, but a 64x64 matrix is pretty hard to create this way.
---API level does not matter at all. I just want this app to run on CM12 phone.
**After creating this app, I'll use a jpg picture of a character for input and refine the processing algorithms. I just need the algorithm to work for this 64x64 binary matrix first**
THE ACTUAL QUESTION:
How do I create the input matrix so it would be swipe-friendly and not bad looking ?
I think if you would like to use the button method you described above, you can call setOnTouchListener() on the buttons. The onTouch method is called when the user touches or swipes over the button so you could put your coloring code in there. But i dont know if a matrix of 64x64 buttons looks nice, that is the other problem
But basically you can as well use other views instead of the buttons because every view has the option to call an onTouchListener
--------------------
Phone: Nexus 4
OS: rooted Lollipop LRX21T
Bootloader: unlocked
Recovery: TWRP 2.8.2.0

Categories

Resources