Languages

Menu
Sites
Language
How to get SIM Subscriber (Phone) Number?

Hi Guys,

I am using samsung Z1 phone for Native Application development. I need to know the SIM card Subscriber number for my app.

I tried below code to get the subscriber number

-----------------------------------------------------------------------------------

    /* telephone init */

    telephony_handle_list_s handle_list;

    int ret = telephony_init(&handle_list);// In case of single SIM, we get only one handle
    if (ret != TELEPHONY_ERROR_NONE){
        dlog_print(DLOG_ERROR, LOG_TAG, "failed to get handle list");
        return;
    }

    /* phone number */
    char *subscriber_number;
    subscriber_number = NULL;
    ret = telephony_sim_get_subscriber_number(handle_list.handle[0], &subscriber_number);
    if (ret != TELEPHONY_ERROR_NONE){
        dlog_print(DLOG_ERROR, LOG_TAG, "Error in fetching phone number");
        return;
    }
    if(subscriber_number != NULL){
        dlog_print(DLOG_INFO, LOG_TAG, "subscriber_number = %s", subscriber_number);
        free(subscriber_number);
    }else{
        dlog_print(DLOG_ERROR, LOG_TAG, "Subscriber number is not stored in SIM Card");
    }

----------------------------------------------------------------------------------------

Above code always print "Subscriber number is not stored in SIM Card" log. Means API got succeeded but it gave NULL subscriber number. 

I added http://tizen.org/privilege/telephony privilege in menifest file.

Do I need partner privilege to get subscriber number?

Thank you.

Responses

3 Replies
Alex Dem

Hi,
I did not face any mention that you need partner privilege level to use this api.
Alrexey

Palitsyna

Hello,

here you can find a list of Tizen privileges with level description(public, partner, platform): 

https://wiki.tizen.org/wiki/Security/Tizen_2.X_Privileges

As you can see, http://tizen.org/privilege/telephony privilege doesn't require partner level.

Dharmesh Guna

Hi Palitsyna,

Thank you for clerifying about privilege.

But what can be possibly wrong with my above code?

I am thinking may be it is SIM card issue.