[Android-development] uid 10084 does not have android.permission.SEND_SMS

David Marceau uticdmarceau2007 at yahoo.ca
Fri Jan 10 23:31:01 CET 2014


Wizard gui for counting trucks and then will send an sms report or email
report at the end of a guard shift.  The sms/email part needs to be
integrated.  I started on the sms send part, but
I have a java.lang.SecurityException: Sending SMS message: uid 10084
does not have android.permission.SEND_SMS.

    W/dalvikvm(10875): threadid=11: thread exiting with uncaught
exception (group=0x4156e930)
    E/AndroidRuntime(10875): FATAL EXCEPTION: Thread-936
    E/AndroidRuntime(10875): java.lang.SecurityException: Sending SMS
message: uid 10084 does not have android.permission.SEND_SMS.
    E/AndroidRuntime(10875):        at
android.os.Parcel.readException(Parcel.java:1425)
    E/AndroidRuntime(10875):        at
android.os.Parcel.readException(Parcel.java:1379)
    E/AndroidRuntime(10875):        at
com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:434)
    E/AndroidRuntime(10875):        at
android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
    E/AndroidRuntime(10875):        at
dalvik.system.NativeStart.run(Native Method)
    I/AndroidRuntime(10875): VM exiting with result code 0, cleanup skipped.



sendSMS using qt for android 5.2.0 c++ qt jni classes.  The source code
for it is here:
http://adequatech.ca/snowloadcount.tar.xz

I did add the appropriate permission in the AndroidManifest.xml file

    My AndroidManifest.xml:
    <?xml version='1.0' encoding='utf-8'?>
    <manifest package="org.kde.necessitas.example.snowloadcount"
android:versionName="1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1">
        <application android:label="@string/app_name"
android:name="org.kde.necessitas.origo.QtApplication"
android:icon="@drawable/icon">
            <activity android:label="@string/app_name"
android:name="org.kde.necessitas.origo.QtActivity"
android:configChanges="orientation|locale|fontScale|keyboard|keyboardHidden">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>
                    <category
android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
                <meta-data android:resource="@array/qt_libs"
android:name="android.app.qt_libs_resource_id"/>
                <meta-data android:resource="@array/bundled_libs"
android:name="android.app.bundled_libs_resource_id"/>
                <meta-data android:value="snowloadcount"
android:name="android.app.lib_name"/>
                <!--  Messages maps -->
                <meta-data
android:value="@string/ministro_not_found_msg"
android:name="android.app.ministro_not_found_msg"/>
                <meta-data android:value="@string/ministro_needed_msg"
android:name="android.app.ministro_needed_msg"/>
                <meta-data android:value="@string/fatal_error_msg"
android:name="android.app.fatal_error_msg"/>
                <!--  Messages maps -->
                <!-- Splash screen -->
                <meta-data android:resource="@layout/splash"
android:name="android.app.splash_screen"/>
                <!-- Splash screen -->
            </activity>
        </application>
        <supports-screens android:smallScreens="true"
android:normalScreens="true" android:largeScreens="true"
android:anyDensity="true"/>
        <uses-sdk android:minSdkVersion="17" android:targetSdkVersion="17"/>
        <uses-permission android:name="android.permission.BROADCAST_SMS"/>
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.READ_SMS"/>
        <uses-permission android:name="android.permission.SEND_SMS"/>
        <uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    </manifest>


The problem area is here:

    void TruckTypeTotalsPage::sendSMS(QString phoneNumber, QString message)
    {
        QAndroidJniEnvironment env;

        //This is the original NON-JNI android java code
        //SmsManager smsManager = SmsManager.getDefault();
        //smsManager.sendTextMessage("Phone Number", null, "Message",
null, null);
        //in background (Not showing message composer)

        //The following attempts to do the same as the above,
        //but using C++/qt for android's JNI classes/apis.
        //HATS OFF to QT FOR ANDROID!

        QAndroidJniObject mySmsManager =
QAndroidJniObject::callStaticObjectMethod("android/telephony/SmsManager", "getDefault",
"()Landroid/telephony/SmsManager;" );
        QAndroidJniObject myPhoneNumber =
QAndroidJniObject::fromString(phoneNumber);
        QAndroidJniObject myTextMessage =
QAndroidJniObject::fromString(message);
        QAndroidJniObject scAddress = NULL;
        QAndroidJniObject sentIntent = NULL;
        QAndroidJniObject deliveryIntent = NULL;
        mySmsManager.callMethod<void>("sendTextMessage",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/app/PendingIntent;Landroid/app/PendingIntent;)V"
, myPhoneNumber.object<jstring>(), scAddress.object<jstring>(),
myTextMessage.object<jstring>(), NULL, NULL );
    }

    This sendSMS() service gets called from a QWizardPage::validate()
callback from a finish button that simply sends a stats report totalling
the number of trucks that dumped their snow at a snow disposal site and
then closes the application.

Does anyone have any solution for getting rid of this error?

Are there any plans to integrate SMS and email apis into the qt toolkit?
vmime and libcurl and can do the email part, but the sms part is highly
dependant on the target os and hardware.  It would be nice to see qt
abstract all this sms/email mess away.

Cheers,
David Marceau



More information about the Android-development mailing list