Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

BlackBerry® World™ Development

Reply
Regular Contributor
Posts: 92
Registered: ‎03-09-2013
My Device: bold 9800
Accepted Solution

Email configured in device or not...

Hello every one, i am working on Blackberry 9800 bold,my native language is java. I am working on a program which will tell me whether mail address is configured on my device or not. Part of my code is given below,but it is not working correctly.. Please any one help me out from this.. :
    ServiceBook sb = ServiceBook.getSB();
                    ServiceRecord[] srs = sb.findRecordsByCid("CMIME");
                    //ServiceRecord[] srs = sb.getRecords();

                    for(int cnt = srs.length - 1; cnt >= 0; --cnt)
                    {
                        //identify the service record associated with a mail message service via a CID of 'CMIME'
                        if( srs[cnt].getCid().equals( "CMIME" ))
                        {
                            Dialog.alert("Mail Address is registered");
                        }
                        else {
                            Dialog.alert("Mail Address is Not registered");
                            UiApplication.getUiApplication().pushScreen(new AgAppdntactUs());    
                            }
                    }

Developer
Posts: 1,452
Registered: ‎11-06-2009
My Device: Torch 9810

Re: Email configured in device or not...

Java forum would be the best place to post questions about Java

http://supportforums.blackberry.com/t5/Java-Development/bd-p/java_dev

 

Anyway, I will comment the issue too. Your approach is wrong on a very basic level. Why? Because you are trying to send mails on behalf of the user. As a user I'm very suspicios to apps, that do things, which I haven't allowed. Besides you have to dial with all kind of scenarios: corporate firewalls, device with no network etc. etc. Moreover I have like 10 mails registered on my device, which one will you pick? I would be very upset to see my personal email used in support-communication (I guess sending user complaints is what you want to achieve)

 

IMO much simpler and easier way to implement this is just to invoke native mail app, populate all fields and let the user hit the Send button. Sample code below:

 

        String to = "test@test.com";
        String subject = "Complaint";
        String body = "Some text";
        Invoke.invokeApplication( Invoke.APP_TYPE_MESSAGES,
            new MessageArguments(MessageArguments.ARG_NEW, to, subject, body));        

 



"When you become a level 3 developer, you learn to communicate over the ether. I'm told that level 5 developers are ascend into a higher level of existence beyond the physical realm." gord888 @ crackberry
Regular Contributor
Posts: 92
Registered: ‎03-09-2013
My Device: bold 9800

Re: Email configured in device or not...

Sir Thank you for your quick response.. Lets suppose i have configure 123@gmail.com on my blackberry device. I want to check the status first in  my application that whether any Mail address is configured on my device or not. If it is configured then it will allow me to send mail, otherwise it will show me dialog box "Configure mail Address". How can i do it?? Please plx help me out there. I will be very thankful to you.

Regular Contributor
Posts: 92
Registered: ‎03-09-2013
My Device: bold 9800

Re: Email configured in device or not...

Actually i am working on an application in which i want to send complain mail to the company, i just provide text box to enter the problem and a send button for sending that problem/complain to the predefined mail address. Thats why i want to make application which will get the status first that whether any mail address is configured on device or not. I am working on Simulator with MDS and ESS where i configured mail address,but i want to make an application in which if I have not configured mail address whether on MDS,ESS or even on Device then it will give me an error dialog box.

Thank You , please help me out there.

Developer
Posts: 1,452
Registered: ‎11-06-2009
My Device: Torch 9810

Re: Email configured in device or not...

IMO skip that check entirely and let the nativa mail app do the job. If the user tries to send an email from native mail app (which you have invoked) and the device doesn't have email address configured, then the user will get a nice warning with instructions what to do. So you don't need to do anything else but only to invoke the native mail app and populate the required fields.



"When you become a level 3 developer, you learn to communicate over the ether. I'm told that level 5 developers are ascend into a higher level of existence beyond the physical realm." gord888 @ crackberry
Regular Contributor
Posts: 92
Registered: ‎03-09-2013
My Device: bold 9800

Re: Email configured in device or not...

I have configured Mail address on simulator using MDS and ESS, and the following code gives me "Email is configured" and I dont configured email on device 9800 bold, so the following code gives me "Email is not configured". It is workind correctly, but I want to make it sure wheter it is the right approach or not? Please do correct me if i am worng.

if(getSelectedIndex()==2)
{
String emailAddress;
try {
Session ourSession = Session.getDefaultInstance();
emailAddress = ourSession.getServiceConfiguration().getEmailAddress();
}

catch ( Exception e )
{
emailAddress = null;
Dialog.alert(emailAddress+"======>email is not configured");
Dialog.alert(emailAddress);
}
if ( emailAddress != null && emailAddress.length() > 0 ) {

Dialog.alert(emailAddress+"=====>123");
Dialog.alert(emailAddress+"email is configured");
emailAddress = emailAddress.toLowerCase();
Dialog.alert(emailAddress);
MethodbyEmail();
}
else
{
Dialog.alert("Email is not configured");
System.exit(0);

}

Developer
Posts: 1,452
Registered: ‎11-06-2009
My Device: Torch 9810

Re: Email configured in device or not...

It seems OK to me.



"When you become a level 3 developer, you learn to communicate over the ether. I'm told that level 5 developers are ascend into a higher level of existence beyond the physical realm." gord888 @ crackberry