Blackberry 8520 message field comes blank - blackberry

In one of my application i need to share link via sms. I am using blackberry OS 5.0. Here is code for sharing message via SMS.
MessageConnection mc = null;
try {
mc = (MessageConnection) Connector.open("sms://");
} catch (IOException e) {
e.printStackTrace();
}
TextMessage textMessage = (TextMessage) mc.newMessage(MessageConnection.TEXT_MESSAGE);
textMessage.setAddress("sms://");
System.out.println("======1====");
textMessage.setPayloadText("afasdfadsfsdaf");
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES,
new MessageArguments(textMessage));
In case of 9810 it shows message box with text. Following is image.
I am using same code for 8520. But image is as follows:-
Please help me out whether it is feasible, if not please share me any specific link for this feature is not feasible.
Thanks

Related

catch System.Reflection.TargetInvocationException

I've created an android application using Xamarin.android that consumes an asmx webservice.the latter connects my app to sql server. the app works perfectly with good internet connection. but when I have bad internet service, I get an exception in visual studio (while deploying my app to a physical device). the exception is: System.Reflection.TargetInvocationException. and when my phone is not connected to my laptop and I run the app with poor connection, my phone gets out from the app. I am trying to catch this exception so that the app doesn't crash and at least give me an alert dialog that my connection failed so I did this:
WSitems.WebService1 ws = new WSitems.WebService1();
try
{
ws.itemsinfoAsync();
ws.itemsinfoCompleted += Ws_itemsinfoCompleted;
}
catch(Exception exp )
{
Context context = this.Context;
AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.SetTitle("Connection to Server failed");
alert.SetMessage("Please, check your internet connection!");
alert.SetPositiveButton("okay",( senderAlert, args) => {
alert.Dispose();
});
_dialog = alert.Create();
_dialog.Show();
}
but the problem wasn't solved. what should I do?
thanks in advance.

Sending messages to specific users in Teams using Graph API

Any endpoint for sending messages to specific users in Teams via the Graph API?
(Edited because of clarity and added Custom-Requests)
You can send messages via Graph API to private users BUT there is a problem that you can't create a new chat between two users via the Graph API. This means that if you want to send a message from a user to a user, the chat must already exist. (Messages must first have been exchanged via the MSTeams client for a chat to exist)
So make sure that you have a open chat!
If so, have a look at this MSDoc (This document explains how you can list chats from a user):
https://learn.microsoft.com/en-us/graph/api/chat-list?view=graph-rest-beta&tabs=http
After you have all your chats listed, you can have a look at this MSDoc (This document explains how you can send a message to a user):
https://learn.microsoft.com/en-us/graph/api/chat-post-messages?view=graph-rest-beta&tabs=http
Pay attention to the permissions! For sending messages and listing chats there are only delegated permissions so far AND these calls are only available in BETA, so be carefull with it.
I can only provide you Java code for an example.
(For everything I do I use ScribeJava to get an Auth-Token)
For delegated permissions you need to have a "User-Auth-Token". That means you have to use a Password-Credential-Grant like this:
private void _initOAuth2Service()
{
oAuth2Service = new ServiceBuilder(clientId)
.apiSecret(clientSecret)
.defaultScope(GRAPH_SCOPE)
.build(MicrosoftAzureActiveDirectory20Api.custom(tenantId));
//PASSWORD CREDENTIALS FLOW
try
{
oAuth2Token = oAuth2Service.getAccessTokenPasswordGrant(username, password);
}
catch (IOException e) { e.printStackTrace(); }
catch (InterruptedException e) { e.printStackTrace(); }
catch (ExecutionException e) { e.printStackTrace(); }
}
username and password are the credentials from the user you want to send a message (sender).
Initial situation
This is my TeamsClient:
ScribeJava
Get all open chats
("me" in the URL is the user from above (sender).)
private Response _executeGetRequest()
{
final OAuthRequest request = new OAuthRequest(Verb.GET, "https://graph.microsoft.com/beta/me/chats");
oAuth2Service.signRequest(oAuth2Token, request);
return oAuth2Service.execute(request);
}
The response I get from this request looks like this:
{"#odata.context":"https://graph.microsoft.com/beta/$metadata#chats","value":[{"id":"{PartOfTheID}_{firstHalfOfUserID}-e52a55572b49#unq.gbl.spaces","topic":null,"createdDateTime":"2020-04-25T09:22:19.86Z","lastUpdatedDateTime":"2020-04-25T09:22:20.46Z"},{"id":"{secondUserChatID}#unq.gbl.spaces","topic":null,"createdDateTime":"2020-03-27T08:19:29.257Z","lastUpdatedDateTime":"2020-03-27T08:19:30.255Z"}]}
You can see that I have two open chats and get two entries back from the request.
Get the right conversatonID
You have to know that the id can be split in three sections. {JustAPartOfTheId}_{userId}#{EndOfTheId}. The {userId} is the id from your chatpartner (recipient).
This is a GraphExplorer response which gives me all users and all informations about them.
Now you can see that the first ID:
"id":"{PartOfTheID}_{firstHalfOfUserID}-e52a55572b49#unq.gbl.spaces"
matches the UserID after the "_".
You can split the ID at the "_" filter and find the ID you need.
Send Message to user
Now you know the right Id and can send a new request for the message like this:
final OAuthRequest request = new OAuthRequest(Verb.POST, "https://graph.microsoft.com/beta/chats/{PartOfTheID}_{firstHalfOfUserID}-e52a55572b49#unq.gbl.spaces/messages");
oAuth2Service.signRequest(oAuth2Token, request);
request.addHeader("Accept", "application/json, text/plain, */*");
request.addHeader("Content-Type", "application/json");
request.setPayload("{\"body\":{\"content\":\" " + "Hi Hi Daniel Adu-Djan" + "\"}}");
oAuth2Service.execute(request);
GraphAPI-Custom-Requests
In the Graph-SDK is no opportunity to use the beta endpoint except for Custom-Requests. (For these requests I also use ScribeJava to get an Auth-Token)
Set the BETA-Endpoint
When you want to use the BETA-Endpoint you have to use the setEndpoint() function like this:
IGraphServiceClient graphUserClient = _initGraphServiceUserClient();
//Set Beta-Endpoint
graphUserClient.setServiceRoot("https://graph.microsoft.com/beta");
Get all chats
try
{
JsonObject allChats = graphUserClient.customRequest("/me/chats").buildRequest().get();
}
catch(ClientException ex) { ex.printStacktrace(); }
Same response like above
Same situation with the userId => split and filter
Send message
IGraphServiceClient graphUserClient = _initGraphServiceUserClient();
//Set Beta-Endpoint again
graphUserClient.setServiceRoot("https://graph.microsoft.com/beta");
try
{
JsonObject allChats = graphUserClient.customRequest("/chats/{PartOfTheID}_{firstHalfOfUserID}-e52a55572b49#unq.gbl.spaces/messages").buildRequest().post({yourMessageAsJsonObject});
}
catch(ClientException ex) { ex.printStacktrace();
}
Here is a little GIF where you can see that I didn't type anything. I just started my little application and it sends messages automatically.
I hope this helps you. Feel free to comment if you don't understand something! :)
Best regards!
As of now, We do not have any endpoint to send messages to specific users via Graph API.
You may submit/vote a feature request in the UserVoice or just wait for the update from the Product Team.
You can vote for a below feature requests which are already created. All you have to do is enter your email ID and vote.
https://microsoftteams.uservoice.com/forums/555103-public/suggestions/40642198-create-new-1-1-chat-using-graph-api
https://microsoftteams.uservoice.com/forums/555103-public/suggestions/39139705-is-there-any-way-to-generate-chat-id-by-using-grap
Update:
Please find below one more user voice created for the same in Microsoft Graph user voices and vote for it.
https://microsoftgraph.uservoice.com/forums/920506-microsoft-graph-feature-requests/suggestions/37802836-add-support-for-creating-chat-messages-on-the-user

Flutter get the phone number

How can I get the mobile phone number of the current phone where the application is running?
For example for this plugin? It would be cool to get the mobile phone number directly.
https://github.com/flutter/plugins/pull/329
this library in dart pub seem to do what you are looking for. check the package linked below:
https://pub.dev/packages/sms_autofill
PhoneFieldHint [Android only]
final SmsAutoFill _autoFill = SmsAutoFill();
final completePhoneNumber = await _autoFill.hint;
There is no way to do this with native Android/iOS code, so also not in Flutter. For example WhatsApp just ask the user to type their number and then sends an SMS with a verification code.
Edit: It is indeed now possible to ask for a phonenumber which makes it easier for the user on Android: https://pub.dev/packages/sms_autofill
However, these are phone numbers known by Google and not necessarily the phone number that is of the phone itself. Also, the user still has to select one themselves and you can't just get the info from the device.
Important: Note that mobile_number plugin asks a very special permission to make phone calls.
sms_autofill do not ask any permissions at all.
Use it like this:
#override
void initState() {
super.initState();
Future<void>.delayed(const Duration(milliseconds: 300), _tryPasteCurrentPhone);
}
Future _tryPasteCurrentPhone() async {
if (!mounted) return;
try {
final autoFill = SmsAutoFill();
final phone = await autoFill.hint;
if (phone == null) return;
if (!mounted) return;
_textController.value = phone;
} on PlatformException catch (e) {
print('Failed to get mobile number because of: ${e.message}');
}
}
There's another package now mobile_number
Its as simple as
mobileNumber = (await MobileNumber.mobileNumber)
Note: It works for Android only, because getting the mobile number of a sim card is not supported in iOS.

lync 2010 sdk can't catch received conversation message

I use lync 2010 sdk and develop with lync wpf application.
I can send message to a group or a person but can't catch the received message text.
like the code ı can catch when a new conversation added, but can't read message text too.
Does anyone know how can ı do it?
private Conversation _conversation;
LyncClient _LyncClient;
void ConversationManager_ConversationAdded(object sender, Microsoft.Lync.Model.Conversation.ConversationManagerEventArgs e)
{
if (_conversation == null)
{
_conversation = e.Conversation;
}
string getmessage=_conversation.GetApplicationData(_AppId);
_conversation.ParticipantAdded += _conversation_ParticipantAdded;
if (_conversation.Modalities[ModalityTypes.InstantMessage].State != ModalityState.Notified)
{
_RemoteContact = _LyncClient.ContactManager.GetContactByUri("sip:xxx #xxx.com.tr");
_conversation.AddParticipant(_RemoteContact);
}
e.Conversation.InitialContextReceived += Conversation_InitialContextReceived;
e.Conversation.ContextDataReceived += Conversation_ContextDataReceived;
e.Conversation.StateChanged += Conversation_StateChanged;
((InstantMessageModality)e.Conversation.Modalities[ModalityTypes.InstantMessage]).InstantMessageReceived += MainWindow_InstantMessageReceived;
}
The events you're using above are for contextual data, which may not be what you want if you want to get IM text. The event you want is the InstantMessageReceived event. It's described in the following article (it's a Lync 2013 article but should work for 2010 as well):
How to: Start a Lync IM conversation
Here you see a screen cap of a section in that article:

How to know the current state of application invoked in blackberry?

Is it possible to know the state of application invoked in blackberry? For example, if we invoke blackberry email application after sending an email, can we know if the application has closed or still running and also where the email has been sent, the subject, the content, etc.? The code may be something like this:
try {
Message message = new Message();
Address address = new Address("email#yahoo.com", "Email");
Address[] addresses = {address};
message.addRecipients(RecipientType.TO, addresses);
message.setContent("Testing email from MyTabViewDemo application");
message.setSubject("Testing Email");
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(message));
log.debug(MyApp.GUID_LOG, "Send email action done!");
} catch (Exception e) {
Dialog.inform(e.toString());
}
and how about retrieving the state of other applications like phone, sms, camera?
Thank you.
You can view the visible applications by calling
ApplicationManager.getApplicationManager().getVisibleApplications();
That returns an array of application descriptors. From a descriptor, you can know the names and ids.
It is possible, however, that the messaging app is always on background and cannot be closed (I'm not 100% sure here)
But you can't know if a message has ben sent or not sending the mail like that.

Resources