Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.
- 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>
- 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.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement