I have an android app that uses the java webview. I am wondering if there is a way to create a button or some kind of link within the app to trigger the device to call a specified number. For example, I'm doing an app for a store, and I'd like to have a button that says Call store. Is this possible?
Making the href of your anchor tag point to a 'tel' URI should do the trick:
Call Us!
If your WebView is using a custom WebViewClient, you may need to implement some special logic in 'shouldOverrideUrlLoading'.
See:
Common Intents - Phone
WebView - Handling Navigation
Related
I want to create a custom notification like inshorts as shown in Image below
And i am able to achieve that as well, shown in screenshot below :
But there are two problem cases:
When i install the app using Android Studio, initially it works fine i.e. Custom Notification layout is displayed for the notification(as shown in picture-3), but when i am killing the app from task manager and then i am sending the notification, it comes as default layout(as shown in picture-4).
When i install the app using the apk on any device, i am getting the notification style as default notification(as shown in picture-4).
I have been stuck in this for long and have changed the whole code of Notification, i am still facing the issue. I am not sure where i am doing wrong.
Picture-3
Picture-4
I was able to achieve what i was looking for i.e. I was looking forward to use the custom layout for showing Notifications eveytime, but the problem was that i was getting custom layout notification if the app used to be in the background and the default notification style when the app is not in the background.
"So what exactly the problem was, Push notifications behave differently in the cases where the app is in background or foreground."
When the app used to be in background the Notification builder code which i have written was being used and the notification with custom layout was displayed. Moreover, when the app used to be in foreground, the android system couldn't reach the notification builder code of my project, in that case notifications were being processed by the Google Service process, which uses the default notification layout.
Solution :
Earlier, the JSON object which i was getting from the server was named as "notification", which generally is used by almost every developer. Changing the name of that JSON object to "data" did the magic.
And the code inside the Notification builder used to be something like this:
String notTitle = remoteMessage.getData().get("title");
which ealier used to be:
String notTitle = remoteMessage.getNotification().getTitle();
This way, my notifications are always being handled by the app, by the NotificationService, and not by the Google Service process.
I hope this helps somebody. :)
I am developing an App that has a lock screen widget where it has a play, pause, prev and next. When I connect my phone to an Android wear, it automatically shows this buttons and it works fine. I would like to add a "Like" button that would automatically be shown on the lock screen and the android wear. I know that I can create a Notification and add action for the like. But I want to know if is it possible to achieve that using only RemoteControlClient?
Have you tried using rating with the flag FLAG_KEY_MEDIA_RATING ? It seems that it's the only way to maintain generic methods and avoid having to set custom code on the wear side (or through notifications).
This flag can be set with setTransportControlFlags
Flag indicating a RemoteControlClient supports ratings. This flag must
be set in order for components that display the RemoteControlClient
information, to display ratings information, and, if ratings are
declared editable (by calling addEditableKey(int) with the
RATING_KEY_BY_USER key), it will enable the user to rate the media,
with values being received through the interface set with
setMetadataUpdateListener(OnMetadataUpdateListener).
Unfortunately, few or not example exists on the web. I discovered only one (unanswered) question relative to this on SO :
Android 4.4 KitKat Rating API
Is there in SDK Android Wear a Class representing a push-button (the push button on the side of the watch)
If it's possible, can I assign a comportment and a method to this push-button, the push-button can be pressed, or clicked, by the user to perform an action.
I found this http://developer.android.com/reference/android/widget/Button. Html
but I think this Class representing a button widget, not what I want
No, there is no way (at this point) to override action for power off button. Also as CurlyCorvus and Nicolas mentioned you provided link to UI Button (not hardware one) class, and you provided screens with non-Android Wear devices.
i would like to ask a question with regards to AlertDialogs which i would like to use in GoogleMaps V2. I read about the custom InfoWindow documentation from the android developers and noticed that they advised not to put any interaction widgets (Buttons, Textbox etc etc) onto an OnClick function. Now, i would like to know if i could use a default alert dialog and put it into an OnClick function for the custom InfoWindow. Is it possible?
Yes that should work fine. The reason why you should not (and cannot, really) put interactive elements in an InfoWindow is because the InfoWinow is statically rendered when shown, making any interactive elements you place in it effectively useless.
Is it possible to add a google plus button added to my android app and have it linked to the one that one that is displayed at the top of the google play store , below the app name? So that when people click the button in the app, the count on the play store would go up.
According to the G+ docs, a +1 button is associated with a particular URL. So, if you can figure out what URL the +1 button in Google Play is associated to, then you should be able to construct a G+ button following the thread here (that I know you've already seen) with that URL and you should be all set. My best guess is that it's the play store URL associated with your app...http://play.google.com/store/apps/details?id=your.package
Sounds like you also want the user to end up in Google Play after they click? If so, just follow the directions here - perhaps you could subclass PlusOneButton or set some click handler on it (calling super) to allow the whole G+ functionality to work before navigating them to the Play Store.