how to make sure whether the telephone has two simcard in my app? - sim-card

before android 5.0,it didn't support two simcard in original android sdk,how to confirm where the phone has two simcard and get the default setting info about the simcard like "which simcard is used to send SMS default"

You can use SubscriptionManager to get the list of active subscriptions:
https://developer.android.com/reference/android/telephony/SubscriptionManager.html#getActiveSubscriptionInfoList()
To get the default SMS subscription ID you can use this API in SmsManager:
http://developer.android.com/reference/android/telephony/SmsManager.html#getDefaultSmsSubscriptionId()

Related

how to send email on Code Name One using Gmail Api

I want to know if There Is a solution to send an email on a Code Name One app using Gmail Api,
i have an exception When i m using javaxmail,
error: cannot find symbol
import java.util.Properties;
symbol: class Properties
thanks in Advance.
You can use Display.sendMessage to send an email in Codename One. However, this is an "interactive" API that will launch the users email client and he'll need to press send to perform the actual emailing.
Alternatively you can use the sendgrid cn1lib to send an email via sendgrid. I would recommend against that though. If you send an email from the device that means your credentials (password etc.) would be on the device. A better way would be to contact your backend server and ask it to send the email for you. That way a hacker can't decompile your app and find out your credentials.
I agree with Shai's response, I'd just like to add a few more thoughts.
Sending emails from a mobile application (regardless of whether it is developed with Codename One) has two major problems:
the first problem, as mentioned by Shai, concerns the credentials: putting your Gmail account inside the client app code is a very bad idea;
the second problem is specifically about Gmail, since you're not referring to a generic mail service, but to Gmail itself: Stack Overflow is not the place to make recommendations on which services to use, however I can tell you why Gmail is probably not what you want to use. The main problem is that Gmail, when used for "third-party apps" (which Gmail considers insecure), doesn't allow you to change IP addresses frequently: if it notices an IP change, it blocks the service and forces you to manually unblock it in the security settings. Obviously the problem is minor if Gmail is contacted by your server that has a static IP address, but it becomes a big problem if Gmail is contacted directly from your users' phones, each of which will have a different IP.
That said, if your app made with Codename One needs to send emails (e.g. to activate new users), I recommend:
your app can use Codename One's Rest class to make a REST call to your RESTful server backend;
in your server, you could use an alternative service to Gmail that doesn't give problems if you change the server IP address every now and then or if you use the server both locally and remotely. For what is my experience, I can tell you that on my Spring Boot server I use org.springframework.mail.javamail.JavaMailSender, which is compatible with various mail services (just for information, I use a free ZohoMail account, however there may be many other alternative and equally valid mail services that I do not know).
As for using Codename One's Rest class, I'll point you to the developer guide (https://www.codenameone.com/developer-guide.html#_rest_api) and to this blog posts: https://www.codenameone.com/blog/terse-rest-api.html and https://www.codenameone.com/blog/new-rest-calls.html
When making Rest calls with Codename One, always keep in mind that there may be no Internet connection or other connectivity issues (or server-side errors), so careful handling of possible errors is critical.

send email on Google App Engine from custom domain

What I have done:
I have added my domain app.mydomain.com to my app engine project, and can successfully visit id.appspot.com using app.mydomain.com.
I have registered mydomain.com on google app for business.
The problem:
The problem is -- I am NOT able to send emails using #mydomain.com address. If I register an info#mydomain.com as an developer, this will probably solve the problem, but we need to send from more than one address, and I don't think registering a new developer for each address is reasonable.
Anybody knows how to solve this? Thanks!
You have two options:
Register all emails that you want to use as administrators/developers but as you mentioned in your post you don't want to do that.
Use SendGrid (or any other email services like Mandrill, Mailgun, etc.) which will give you a lot more features comparing to what GAE offers, including 25k free emails instead of GAE's 100.
According to the docs, the sender would need to be an administrator on the project (called "owner" in the new Developers Console). Another route would be to just use a separate email sending service like SendGrid or Postmark.
You can use the GMail API to send emails as users of your domain. Note that the emails need to be aliases, groups or users of your domain.
You shouldn't have any problem adding and verifying your domain, adding the necessary permissions to send emails. Then, every email address in your domain can be used. See here in the docs: https://developers.google.com/appengine/docs/java/mail/#Java_Sending_mail

How do I get device related info programmatically like model number or IMSI , MSISDN while developing codenameone app

I am developing a codename app and need to capture device model ,imsi and msisdn information so that i can send data depending on this information.
Try Display.getInstance().getUdid() and Display.getInstance().getMsisdn() you can also use Display.getInstance().getProperty(...) for more properties.

Is it possible to set signatures for each approved "send mail as" through the Google Apps Email Settings API?

I have a Google Apps account with two others approved "Send mail as" accounts. In the Gmail settings (web interface) I can set one signature for each of the three email addresses.
Is it possible to do the same through the Googe Apps Email Settings API so that I can automate this for the entire organization?
The API documentation (https://developers.google.com/google-apps/email-settings/#manage_signature_settings) does only mention how to define username, but gives no options for specifying the actual email address for that username to set the signature for.
It's not currently possible, no. The Email Settings API only supports setting the signature for the primary email address.
I think there are some 3rd-party apps that can do this but - and it's a big one - it depends on what program you're sending the mail from.
If you're using Outlook, you can use Exclaimer Signature Manager. The point of that software is to control every user's email signature. You could give them multiple signatures to choose from, thus, deciding which one they need based on their 'Send From' setting.
There are other apps, but I don't think any of them do that.
And if you're emailing in a browser, you're out of luck. I don't know if Exclaimer have or are working on a Google Apps-dedicated product, it may be worth checking.
The newer Gmail API allows setting per-address signatures. See the "Aliases and signatures" guide. Only service accounts that have been delegated domain-wide authority can update signatures for non-primary addresses.

How to send and recive text in windows phone using silverlight?

I want to send a message from a windows phone to other windows phone via web services.
How can I do that?
Make use of Push Notifications. They are used to initiate an activity on a phone from a third party. There are three types of them: Tile Notification, Toast Notification and Raw Notification.
Toast Notifications (Example: SMS alert) are received when the application is not running. If for some reason sending from one phone to another implies that both of them run at the same time, consider using Raw Notifications. However, I suppose you should use both of them: if a Raw Notification is dropped (this usually means that the application is not running in the foreground), send Toast Notification.
As far as I undestand your requirements, you should do the following:
Once the application is started (or a user is logged in), establish Push channel and request PushUri for the phone from Microsoft Push Notification Server
Send the PushUri to your service, associate it with the user and save it.
To send a message to a phone application, just pass appropriate parameters to its PushUri. You can do this either from your web service or directly from another phone.
You may find the documentation useful. There are examples of how to establish, send and receive them.
P.S. Take into account that the second Toast Notification may fail as well because during the timespan between two Notifications the user may launch your application. Don't forget to handle this.

Resources