public class PanicTrigger
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
TAG |
| Constructor and Description |
|---|
PanicTrigger() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
addConnectedResponder(android.content.Context context,
java.lang.String packageName)
Add a
packageName to the list of connected responders. |
static boolean |
checkForConnectIntent(android.app.Activity activity)
Checks whether the provided
Activity was started with the action
Panic.ACTION_CONNECT, and if so, processes that Intent ,
adding the sending app as the panic trigger. |
static boolean |
checkForDisconnectIntent(android.app.Activity activity)
Checks whether the provided
Activity was started with the action
Panic.ACTION_DISCONNECT, and if so, processes that Intent
, removing the sending app as the panic trigger if it is currently
configured to be so. |
static boolean |
disableResponder(android.content.Context context,
java.lang.String packageName)
Remove a
packageName to the list of responders that will receive a trigger from this app. |
static boolean |
enableResponder(android.content.Context context,
java.lang.String packageName)
Add a
packageName to the list of responders that will receive a trigger from this app. |
static java.util.Set<java.lang.String> |
getAllResponders(android.content.Context context)
Get the
Set of all packageNames of installed apps that include
any Activity, BroadcastReceiver, or
Service that responds to Panic.ACTION_TRIGGER
Intents. |
static java.util.Set<java.lang.String> |
getConnectedResponders(android.content.Context context)
Get the
Set of packageNames of any Activitys or
Services that respond to Panic.ACTION_TRIGGER
and have been manually connected by the user to this app. |
static java.util.Set<java.lang.String> |
getEnabledResponders(android.content.Context context)
Get the
Set of packageNames of any Activitys or
Services that respond to Panic.ACTION_TRIGGER
and have been enabled by the user |
static java.util.Set<java.lang.String> |
getResponderActivities(android.content.Context context)
|
static java.util.Set<java.lang.String> |
getResponderBroadcastReceivers(android.content.Context context)
|
static java.util.Set<java.lang.String> |
getResponderServices(android.content.Context context)
|
static java.util.Set<java.lang.String> |
getRespondersThatCanConnect(android.content.Context context)
Get all of the responders that are able to make a full connection using
Panic.ACTION_CONNECT, which is used to configure the response an
app makes. |
static boolean |
removeConnectedResponder(android.content.Context context,
java.lang.String packageName)
Remove a
packageName from the list of connected responders. |
static void |
sendTrigger(android.content.Context context)
Send a basic
Panic.ACTION_TRIGGER Intent to all
configured panic receivers. |
static void |
sendTrigger(android.content.Context context,
android.content.Intent intent)
Send the
Intent to all configured panic receivers. |
public static final java.lang.String TAG
public static boolean checkForConnectIntent(android.app.Activity activity)
Activity was started with the action
Panic.ACTION_CONNECT, and if so, processes that Intent ,
adding the sending app as the panic trigger.activity - the Activity to check for the IntentACTION_DISCONNECT Intent was receivedpublic static boolean checkForDisconnectIntent(android.app.Activity activity)
Activity was started with the action
Panic.ACTION_DISCONNECT, and if so, processes that Intent
, removing the sending app as the panic trigger if it is currently
configured to be so.activity - the Activity to check for the IntentACTION_DISCONNECT Intent was receivedpublic static boolean addConnectedResponder(android.content.Context context,
java.lang.String packageName)
packageName to the list of connected responders.context - the app's ContextpackageName - the responder to addremoveConnectedResponder(Context, String)public static boolean removeConnectedResponder(android.content.Context context,
java.lang.String packageName)
packageName from the list of connected responders.context - the app's ContextpackageName - the responder to removeaddConnectedResponder(Context, String)public static boolean enableResponder(android.content.Context context,
java.lang.String packageName)
packageName to the list of responders that will receive a trigger from this app.context - the app's ContextpackageName - the responder to adddisableResponder(Context, String)public static boolean disableResponder(android.content.Context context,
java.lang.String packageName)
packageName to the list of responders that will receive a trigger from this app.context - the app's ContextpackageName - the responder to addenableResponder(Context, String)public static java.util.Set<java.lang.String> getResponderActivities(android.content.Context context)
context - the app's ContextpackageNames of responder Activitysto get the {@link android.app.Service}s,
to get the {@link android.content.BroadcastReceiver}spublic static java.util.Set<java.lang.String> getResponderBroadcastReceivers(android.content.Context context)
Set of packageNames of all
BroadcastReceivers that respond to
Panic.ACTION_TRIGGER. Unlike with Services and
Activitys, a BroadcastReceiver cannot verify which app
sent this Intent to it.
BroadcastReceivers are not able to verify which app sent this.
context - the app's ContextpackageNames of responder BroadcastReceiversto get the {@link Activity}s,
to get the {@link android.app.Service}spublic static java.util.Set<java.lang.String> getResponderServices(android.content.Context context)
Set of packageNames of all Services
that respond to Panic.ACTION_TRIGGER.
Services are not able to verify which app sent this.
context - the app's ContextpackageNames of responder Servicesto get the {@link Activity}s,
to get the {@link android.content.BroadcastReceiver}spublic static java.util.Set<java.lang.String> getAllResponders(android.content.Context context)
Set of all packageNames of installed apps that include
any Activity, BroadcastReceiver, or
Service that responds to Panic.ACTION_TRIGGER
Intents.context - the app's ContextpackageNames of responder appsto get the {@link Activity}s,
to get the {@link android.content.BroadcastReceiver}s,
to get the {@link android.app.Service}s,
getEnabledResponders(Context)public static java.util.Set<java.lang.String> getConnectedResponders(android.content.Context context)
Set of packageNames of any Activitys or
Services that respond to Panic.ACTION_TRIGGER
and have been manually connected by the user to this app.context - the app's ContextpackageNames of responder apps that are
currently to this trigger appcheckForConnectIntent(Activity),
checkForDisconnectIntent(Activity),
getAllResponders(Context),
getEnabledResponders(Context)public static java.util.Set<java.lang.String> getEnabledResponders(android.content.Context context)
Set of packageNames of any Activitys or
Services that respond to Panic.ACTION_TRIGGER
and have been enabled by the usercontext - the app's ContextpackageNames of responder apps that are
currently to this trigger appcheckForConnectIntent(Activity),
checkForDisconnectIntent(Activity),
getAllResponders(Context),
getConnectedResponders(Context)public static java.util.Set<java.lang.String> getRespondersThatCanConnect(android.content.Context context)
Panic.ACTION_CONNECT, which is used to configure the response an
app makes. For destructive responses, it is essential that the trigger
and responder are connected in order to prevent random apps from making
responders destroy things. Apps can also only respond to
Panic.ACTION_TRIGGER with a non-destructive response which does
not require the apps to connect or the user to configure anything.context - the app's ContextpackageNames of responder apps that can connect
to a trigger apppublic static void sendTrigger(android.content.Context context)
Panic.ACTION_TRIGGER Intent to all
configured panic receivers. See sendTrigger(Context, Intent)
if you want to use a custom Intent that can include things
like a text message, email addresses, phone numbers, etc.
Only the receiving Activitys will be able to verify which app sent this,
Services and BroadcastReceivers
will not.
WARNING: If the receiving apps must be able to verify
which app sent this Intent, then context must be
an instance of Activity. Also, that Activity cannot have
android:launchMode="singleInstance" (because it is not possible
to get the calling Activity, as set by
Activity.startActivityForResult(Intent, int, Bundle))
context - the Context that will send the trigger Intent,
If this is an instance of Activity, then the receiving
apps will be able to verify which app sent the Intentjava.lang.IllegalArgumentException - if not a Panic.ACTION_TRIGGER
Intentpublic static void sendTrigger(android.content.Context context,
android.content.Intent intent)
Intent to all configured panic receivers. It must have
an action of Panic.ACTION_TRIGGER or a
IllegalArgumentException will be thrown. The Intent can
include things like a text message, email addresses, phone numbers, etc.
which a panic receiver app can use to send the message.
Only the receiving Activitys will be able to verify which app sent this,
Services and BroadcastReceivers
will not.
WARNING: If the receiving apps must be able to verify
which app sent this Intent, then context must be
an instance of Activity. Also, that Activity cannot have
android:launchMode="singleInstance" (because it is not possible
to get the calling Activity, as set by
Activity.startActivityForResult(Intent, int, Bundle))
context - the Context that will send the trigger Intent,
If this is an instance of Activity, then the receiving
apps will be able to verify which app sent the Intentintent - the Intent to send to panic respondersjava.lang.IllegalArgumentException - if not a Panic.ACTION_TRIGGER
Intent