Intent setAction ACTION_SNOOZE retired? - android

hmm, even the android developer page:
Developers
shows this line in the example for notification 'snooze' code:
snoozeIntent.setAction(ACTION_SNOOZE);
but when I try to use it in my Android Studio (3.6.1), it doesn't accept it (or offer it when asking for list of ACTION_ suggestions).
Google is not my friend here, any idea what's wrong on my side?

I think in this case you do not use a predefined 'Intent.ACTION_...'. Instead you create your own constant, being a String, and retrieve this when accepting the intent with 'getAction()'.
For the official link:
https://developer.android.com/reference/android/content/Intent#setAction(java.lang.String)
Although it does not specify such behavior explicitly, it is okay to do this. Unfortunate the guide about 'Notifications' did not expanded on this subject. However, you can see a similar behavior being done with the CHANNEL_ID oa.
As an extra:
If you define your own actions, be sure to include your app's package name as a prefix, as shown in the following example:
Link: https://developer.android.com/guide/components/intents-filters#Building

Related

How to access linkify number

I need to make all numbers in a string become links.
The expected action when any of these links is clicked is to append the clicked number to an existing string.
I managed to linkify the numbers by using the following code:
Pattern myMatcher = Pattern.compile("[0-9]*");
Linkify.addLinks(myString, myMatcher, null);
How can I access and retrieve the clicked number in this case?
I tried looking in other questions related to Linkify but seems all are describing ways to have an action that opens an activity or open the default app for that link type (email address/web URL/etc.)
Thanks in advance for you help :)
You can Customize Linkify to append any predefiened string(scheme) into that.
Take a look at the following post Android Developer Blogspot (Search for "Custom Linkify")
For clarity I am describing a portion of that post here:
Linkify will automatically append whatever is matched to a scheme that
is supplied to it, so for the sake of argument let's assume we have a
ContentProvider that matches the following content URI:
content://com.google.android.wikinotes.db.wikinotes/wikinotes/WikiWord
The WikiWord part will be appended by Linkify when it finds a match,
so we just need the part before that as our scheme.
Now that we have these two things, we use Linkify to connect them up:
Pattern wikiWordMatcher = Pattern.compile("\\b[A-Z]+[a-z0-9]+[A-Z][A-Za-z0-9]+\\b");
String wikiViewURL = "content://com.google.android.wikinotes.db.wikinotes/wikinotes/";
Linkify.addLinks(noteView, wikiWordMatcher, wikiViewURL);
Linkify can be used multiple times on the same view to add more links,
so using this after the Default Linkify call means that the existing
active links will be maintained and the new WikiWords will be added.
You could define more Linkify actions and keep applying them to the
same TextView if you wanted to.
Now, if we have a WikiWord in the TextView, let's say MyToDoList,
Linkify will turn it into an active link with the content URI:
content://com.google.android.wikinotes.db.wikinotes/wikinotes/MyToDoList
and if you click on it, Android will fire the default intent for that
content URI.
For this to all work, you will need a ContentProvider that understands
that Content URI, and you will need a default activity capable of
doing something with the resulting data. I plan to cover these in
future blog entries (and soon). In fact, the whole Wiki Note Pad
application is currently undergoing some clean up and review, and will
then hopefully be released as a sample application.

Change the title of Paypal PaymentActivity class

I included paypal sdk in the app and set the product name and price as shown in the attached image.
Is it possible to change the title of the paypal PaymentActivity class . ?
I used the entire code for paypal from this link
.Please suggest whether we could change the title to any text ,(I want to change the text that is marked in Red Circle)?
Jeff here from the PayPal Mobile SDK team.
The PayPal Android SDK doesn't support modifying any of the SDK activities. We don't plan to allow the ability to modify titles, as this would be an inconsistent user experience. However, we're open to feedback from users, so please feel free to file issues in GitHub if you have feature requests!
Couple observations, apparently:
The activity of off which you have put screenshot is PaymentMethodActivity (according to Hierarchy Viewer)
PayPal SDK uses ABS
According to the sample app provided in PayPal SDK page, onBuyPressed() launches PaymentActivity with startActivityForResult():
Now, according to SDK references, PaymentActivity does not provide any API for setting custom title. The page lists setTitle() as a part of "Methods inherited from class android.app.Activity", but does not give any details on how to extend PaymentActivity so that one could leverage those APIs.
So, currently, there is no way to use a custom title.
I personally would not bother to change the title on that screen as it clearly depicts itself as a PayPal screen (as one would see their homepage on a browser), but if you really want a custom title, you may need to file a new issue on their GitHub page.
Your AndroidManifest.xml file should have an entry for the PaymentActivity that looks like this:
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
All you should have to do is add the label attribute to that to change the title:
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" android:label="#string/some_title" />
For other potentially useful attributes, refer to the activity tag documentation.
Note: I'm assuming here that the PayPal SDK will allow you to override the title. That is, I would expect it to only set a default title if none is given explicitly.
Edit: Unfortunately, the assumption above has proven to be incorrect. Diving a little deeper, it turns out every activity in the PayPal SDK always sets its title in the onCreate() method. That's actually a little surprising, because that means that PayPal isn't leveraging Android's built-in support for localisation and resources. Although I suppose it does allow them to offer developers the SDK as a jar, which doesn't support bundling Android resources.
In any case, since the various activities haven't been declared final, you could simply try to extend them and set the title after the super has done its work:
public class TitlePaymentMethodActivity extends PaymentMethodActivity {
#Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Custom Title")
// or:
setTitle(R.string.custom_title);
}
}
After that, you'll have to change the manifest to point to your TitlePaymentMethodActivity, in stead of directly to the activity in the SDK. Do note that this approach may break at any point, if PayPal decides to finalize the activity classes. With that in mind, I suggest you follow #shoe rat's recommendation and file a request with PayPal for 'official' support.

Can we use a EditText for creating hyperlinks?

We can use a TextViewfor adding hyperlinks to it by various methods, like using the attribute autoLink, or by using setMovementMethod().
Can we do the same using and EditText widget? I am trying to create a notepad, in which if any such text entered, like url, email, number or something similar, we should get a hyperlink to click on it and open the browser.
Please help.
Thanks All.
As of Android API level 8 there is a WEB_URL pattern. Quoting the source, it "match[es] most part of RFC 3987". If you target a lower API level you could simply copy the pattern from the source and include it in your application. I assume you know how to use patterns and matchers, so I'm not going into more details here.
Also the class URLUtil provides some useful methods, e.g:
isHttpUrl()
isValidUrl()
The descriptions of the methods are not very elaborate, therefore you are probably best of looking at the source and figuring out which one fits your purpose best.
As for when to trigger the validation check, there are multiple possibilities: you could use the EditText callback functions
onFocusChanged(), or
onTextChanged()
or use a TextWatcher, which I think would be better.
I hope this helps, best regards,

What's the correct way to specify an intent action in Manifest File?

The tutorial says to use android.appwidget.action.APPWIDGET_UPDATE in the action element within the XML intent-filter.
However,
this is the value of a String constant ACTION_APPWIDGET_UPDATE in
android.appwidget.AppWidgetManager
-- I am new to Android but in general programming it is encouraged to use symbolic constants rather than literal values.
Can I use android.appwidget.AppWidgetManager.ACTION_APPWIDGET_UPDATE in my xml file rather than "android.appwidget.action.APPWIDGET_UPDATE"?
This is somewhat of a good practices question rather than a get-me-unstuck one.
Please use your custom intent filter action value within res/value/String.xml file and use it in all place where required i.e., manifest.xml as well as other java files.
I think this is the best way i found. Because you have to use changes at only one place and it reflects in every referred places.
Thank you,
The answer is no, Android does not allow it, and I cannot think of a compelling reason why. The question asks specifically about a standard Android string literal, rather than a custom string literal, hence I am not accepting the other answer (which is still a good answer so upvoting).

Android LogCat Filter for multiple tags in Eclipse

Clicked on create filter could not figure out from docs how to create a filter for say two or more tags. If I have two tags com.test.TestClassA and com.test.TestClassB how do I create a filter that shows log for both of these classes? I saw how you can start ADB for only certain tags, but how can this be done in eclipse? Please provide details thanks. What exactly do I need to enter on the tag line when creating a new filter in eclipse?
As pointed by Brain Reinhold you can combine tag filters with vertical bar | (which obviously means logical "OR"). You can also use that (as well as other Regex) syntax in the logcat search box (by preceding tags with tag: prefix):
tag:com.test.TestClassA|com.test.TestClassB
More complex filtering is also possible. For example here is the search filter that displays messages from either android.process.media or com.android.camera apps, which have at least one digit (\d) in the message text and are tagged with either dalvikvm or AndroidRuntime tags:
app:android.process.media|com.android.camera tag:dalvikvm|AndroidRuntime text:\d
One short and useful filter is tag:^(?!dalvikvm) which removes all those noisy Dalvik logs.
It's also worth mentioning that you can quickly disable any part of the filter by placing vertical bar at the end of the part you wish to disable (e.g. placing | right after app:android.process.media|com.android.camera in the example above effectively disables filtering by application name while still preserving filtering by tags and text).
In the latest version of the SDK for Eclipse which now shows two versions for logcat (one deprecated); in the undeprecated version one can combine filters using OR bars: |.
For example when clicking on the + and bringing up a dialog to create a new filter, give your filter a name and then in one of the fields (for example TAG) enter com.lampreynetworks|Bluetooth and you will see output for all tags containing com.lampreynetworks and Bluetooth. The '*' is implicit here as if any part of the TAG contains any of that text it will be displayed. Also note, there must be no spaces between the OR bars!
I have not tried combining the 'by TAG' and 'by (some other option)' but somehow I have a feeling that will not work.
On Feb 12, 2:58 am, AndroidDevTime wrote:
If I have two tags
com.test.TestClassA and com.test.TestClassB how do I create a filter
that shows log for both of these classes?
The "Log tag" field accepts Java regular expressions, so do this:
^com.test.TestClassA$|^com.test.TestClassB$
which matches exactly those tags you specified. You could be more economical/efficient/whatever with the regular expression, depending on how much you want to muck around with that.
It is not possible right now.
#see http://groups.google.com/group/android-developers/browse_thread/thread/17356ef7bdf1550f?pli=1
I also wish it were...
I just do it from the command line. Having a different terminal for each adb filter. Then if you line them up side by side you can get a good idea of what is happening.
The only way I have seen is Create a Filter using PID so that evey log message of your application will be displayed in that Filter. I wonder if this is possible through tag names in the current version of the ADT for eclipse.
Use proclogcat: http://devtcg.blogspot.com/2010/04/logcat-improved.html
It lets you filter by your package name instead.

Categories

Resources