-
-
Notifications
You must be signed in to change notification settings - Fork 814
Open intent
OPEN INTENT IS NOT IMPLEMENTED YET!
Xabber supports XMPP URI Scheme Query Components.
It makes possible to click hyperlink like
xmpp:contact@example?message
from another application to open chat with [email protected].
If more than one account contains [email protected], choose dialog will be shown.
Uri
xmpp://[email protected]/[email protected]?message;body=Hello%20world!
can be used to open chat with [email protected] for [email protected] having “Hello world!” text already entered.
To trigger Xabber from your application you can use Intent:
Intent intent = new Intent(Intent.ACTION_VIEW); Uri uri = new Uri.Builder() .scheme("xmpp") .authority("[email protected]") .path("[email protected]") .encodedQuery("message;body=" + Uri.encode("Hello word!")) .build(); intent.setData(uri); startActivity(intent);
To preform an action without user confirmation broadcast with “com.xabber.android.action.PERFORM” action and appropriated data should be used.
Required permissions are described below.
For example to change status from your application you can use:
Intent intent = new Intent("com.xabber.android.action.PERFORM"); Uri uri = new Uri.Builder() .scheme("xmpp") .authority("[email protected]") .encodedQuery("status;mode=chat;text=" + Uri.encode("Sun shine!")) .build(); intent.setData(uri); sendBroadcast(intent);
AndroidManifest.xml
should contains:
<uses-permission android:name="com.xabber.android.permission.STATUS" />
“com.xabber.androiddev.action.PERFORM” and “com.xabber.androidvip.action.PERFORM” actions should be used for development and vip version.
Uri:
xmpp:[//[email protected]/][email protected]?message[;body=<text>]
Description: Opens chat.
Key | Value | Description |
body | Text value | Optional text to be sent |
The permission required for automatic preform:
- com.xabber.android.permission.MESSAGE
Uri:
xmpp:[//[email protected]]?status[;mode=<mode>][;text=<text>]
Description: Opens status change activity.
Key | Value | Description |
mode | One of the following values: “chat”, “available”, “away”, “xa”, “dnd”, “unavailable” | Status mode. |
text | Text value | Status text. |
The permission required for automatic preform:
- com.xabber.android.permission.STATUS
The permission required for change mode from or to “unavailable” value:
- com.xabber.android.permission.CONNECTION
Uri:
xmpp://[email protected]?account[;enable=True|False]
Description: Change account settings.
Key | Value | Description |
enable | One of the following values: “true”, “false” | Whether account should be listed in contact list. |
The permission required for automatic preform:
- com.xabber.android.permission.CONNECTION
Uri:
xmpp:?exit
Description: Closes application.
Note: Please use this action instead of killing application in order to prevent data loss.
The permission required for automatic preform:
- com.xabber.android.permission.EXIT
Some actions require account’s bare jid (localpart@domainpart without resource part) as an URI authority.
External application can list accounts using getAccountsByType.
Note: this method requires the caller to hold the permission GET_ACCOUNTS.
Available account types are:
- com.xabber.android
- com.xabber.androiddev
- com.xabber.androidvip
Content provider is to be implemented in order to provide list of accounts without system contact list integration enabled.
Not all of query types and keys defined here are presented in the “registry”:http://xmpp.org/registrar/querytypes.html maintained by XMPP Standards Foundation.
The delimiter between key-value pairs is the ‘;’ character instead of the ‘&’ character used in many other URI schemes. This delimiter has been chosen in order to avoid problems with escaping the ‘&’ character in HTML and XML applications RFC-5122.
Workaround for NullPointerException in Android 1.5:
uri = Uri.parse(uri.toString());