0

I have been learning Android Studio, and im really stuck. This morning i had a code that send SMS's quite easly. But, now for some reason it is no longer working.

This is the code i have:

public void onClick(View v)
{
    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage("9082300752", null, "10" , null, null);
}

I added the permission in the Manifest

 <uses-permission android:name="android.permission.SEND_SMS"/>

And i imported:

import android.telephony.SmsManager;

I still get the error

12-07 16:36:03.028 20796-20796/com.example.owen.smstest D/HtcTelephonyCapability﹕ traditional single GSM/CDMA/World-phone

12-07 16:36:03.028 20796-20796/com.example.owen.smstest D/HtcTelephonyCapability﹕ The project is not dual project , phone_feature_type_stand_by = 0

12-07 16:36:03.028 20796-20796/com.example.owen.smstest D/HtcBuildUtils﹕ getRATByHtcTelephonyCapability:1

12-07 16:36:03.038 20796-20796/com.example.owen.smstest W/SystemReader﹕ Cannot find qct_8960_interface, use default value instead

Im out of ideas, any help would be greatly appreciated.

2 Answers2

0

Forgive me if I'm wrong, but the phone number doesn't seem right. Include country code and try again.

I don't suppose this would help, but also try adding the following permission:

<uses-permission android:name="android.permission.WRITE_SMS" />

Can you tell us maker/model of your phone? Is it dual SIM? If yes, is default SIM set? What else does your app do?

Budimir Grom
  • 756
  • 6
  • 12
0

In AndroidManifest.xml Add intent-filter in the activity that will send SMS message, Like this:

    <activity
        android:name=".Player2"
        android:label="@string/title_activity_player2" >
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <action android:name="android.intent.action.SENDTO" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="sms" />
            <data android:scheme="smsto" />
            <data android:scheme="mms" />
            <data android:scheme="mmsto" />
        </intent-filter>
    </activity>

Tested for HTC M8

OKAMS7
  • 31
  • 8