public class ContentUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
LOG_TAG |
static java.lang.String |
MIMETYPE_TEXT_PLAIN
MIME type "text/plain"
|
static java.lang.String |
QUERY_ORDER_ASCENDING
The magic word used by
ContentResolver.query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String) to
specify that results should be sorted in ascending order. |
static java.lang.String |
QUERY_ORDER_DESCENDING
The magic word used by
ContentResolver.query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String) to
specify that results should be sorted in descending order. |
static java.lang.String |
QUERY_VARIABLE_MARKER
The character that stands in for a variable value in the Android format
string that is supplied to methods of
ContentResolver . |
static android.content.ClipboardManager |
s_mgrClipboard
A persistent reference to the system's clipboard manager.
|
Constructor and Description |
---|
ContentUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
copyTextToClipboard(android.content.Context ctx,
int resText)
Copies the specified plain text into the clipboard.
|
static void |
copyTextToClipboard(android.content.Context ctx,
java.lang.String sText)
Copies the specified plain text into the clipboard.
|
static void |
copyTextToClipboard(android.content.Context ctx,
java.lang.String sClipLabel,
int resText)
Copies the specified plain text into the clipboard.
|
static void |
copyTextToClipboard(android.content.Context ctx,
java.lang.String sClipLabel,
java.lang.String sText)
Copies the specified plain text into the clipboard.
|
static android.content.ClipboardManager |
getClipboardManager(android.content.Context ctx)
Retrieves the system's clipboard manager.
|
static void |
shareText(android.content.Context ctx,
java.lang.String sText)
Opens the OS-standard "share" dialog, using the specified text content to
be shared.
|
static void |
shareText(android.content.Context ctx,
java.lang.String sText,
int resTitle)
Opens the OS-standard "share" dialog, using the specified text content to
be shared.
|
static void |
shareText(android.content.Context ctx,
java.lang.String sText,
java.lang.String sTitle)
Opens the OS-standard "share" dialog, using the specified text content to
be shared.
|
static boolean |
tryToTweetText(android.content.Context ctx,
java.lang.String sTweet)
As
tweetText(Context, String) , but catches the possible
UnsupportedEncodingException internally, by logging an error. |
static void |
tweetText(android.content.Context ctx,
java.lang.String sTweet)
Dispatches an intent to view Twitter's "tweet" intent page, using the
specified text as the contents of the tweet.
|
static boolean |
unregister(android.content.Context ctx,
android.content.BroadcastReceiver rcv)
Safe and idempotent method for unregistering a
BroadcastReceiver
which might or might not still be registered in the given
Context . |
protected static final java.lang.String LOG_TAG
public static final java.lang.String QUERY_ORDER_ASCENDING
ContentResolver.query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String)
to
specify that results should be sorted in ascending order.public static final java.lang.String QUERY_ORDER_DESCENDING
ContentResolver.query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String)
to
specify that results should be sorted in descending order.public static final java.lang.String QUERY_VARIABLE_MARKER
ContentResolver
.public static final java.lang.String MIMETYPE_TEXT_PLAIN
public static android.content.ClipboardManager s_mgrClipboard
public static android.content.ClipboardManager getClipboardManager(android.content.Context ctx)
ctx
- the context from which to retrieve the manager instancepublic static void copyTextToClipboard(android.content.Context ctx, java.lang.String sClipLabel, java.lang.String sText)
ctx
- the context in which to operatesClipLabel
- the "label" of the new clipboard itemsText
- the plain text to be copiedClipboardManager.setPrimaryClip(ClipData)
public static void copyTextToClipboard(android.content.Context ctx, java.lang.String sText)
R.string#app_name
resource, which is usually the name of the
current app.ctx
- the context in which to operatesText
- the plain text to be copiedClipboardManager.setPrimaryClip(ClipData)
public static void copyTextToClipboard(android.content.Context ctx, java.lang.String sClipLabel, int resText)
ctx
- the context in which to operatesClipLabel
- the "label" of the new clipboard itemresText
- the resource ID of the text to be added to the clipboardClipboardManager.setPrimaryClip(ClipData)
public static void copyTextToClipboard(android.content.Context ctx, int resText)
R.string#app_name
resource, which is usually the name of the
current app.ctx
- the context in which to operateresText
- the resource ID of the text to be added to the clipboardClipboardManager.setPrimaryClip(ClipData)
public static void shareText(android.content.Context ctx, java.lang.String sText, java.lang.String sTitle)
ctx
- the context in which to open the dialogsText
- the text to be sharedsTitle
- the title of the dialogpublic static void shareText(android.content.Context ctx, java.lang.String sText, int resTitle)
ctx
- the context in which to open the dialogsText
- the text to be sharedresTitle
- the resource ID of the string for the dialog titlepublic static void shareText(android.content.Context ctx, java.lang.String sText)
R.string#title_diaShare_default
provided by this library, which
may be overridden in the app that consumes this library.ctx
- the context in which to operatesText
- the text to be sharedpublic static void tweetText(android.content.Context ctx, java.lang.String sTweet) throws java.io.UnsupportedEncodingException
ctx
- the context in which to attempt the tweetsTweet
- the tweet textjava.io.UnsupportedEncodingException
- if the tweet text cannot be
URL-encoded in UTF-8, as specified within the functionpublic static boolean tryToTweetText(android.content.Context ctx, java.lang.String sTweet)
tweetText(Context, String)
, but catches the possible
UnsupportedEncodingException
internally, by logging an error.ctx
- the context in which to attempt the tweetsTweet
- the tweet texttrue
if the attempt succeeded, or false
if an
UnsupportedEncodingException
was caughtpublic static boolean unregister(android.content.Context ctx, android.content.BroadcastReceiver rcv)
BroadcastReceiver
which might or might not still be registered in the given
Context
.ctx
- the context in which the receiver might be registeredrcv
- the receiver to be unregisteredtrue
only if the unregister operation was completed
without throwing an exception