Android Question MMS/SMS attachment?

tekh2999

Member
Licensed User
Longtime User
Can someone explain to me why I see no attachment.

B4X:
 Sub Button6_Click
Dim iIntent As Intent
iIntent.setType("vnd.android-dir/mms-sms")
iIntent.PutExtra("android.intent.extra.STREAM", CreateUri("file://" & File.Combine(File.DirDefaultExternal, "FI1.JPEG")))
iIntent.PutExtra("sms_body", "Hello there!!!")
iIntent.PutExtra("address", "01234567899")
iIntent.SetType("image/JPEG")
iIntent.SetComponent(".ComposeSmsActivity")
StartActivity(iIntent)
  End Sub
Sub CreateUri(Uri As String) As Object
    Dim r As Reflector
    Return r.RunStaticMethod("android.net.Uri", "parse", Array As Object(Uri), Array As String("java.lang.String"))         
End Sub


heres my manifest and I know this is probably wrong:

AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
addPermission("android.permission.READ_EXTERNAL_STORAGE")
AddPermission("android.permission.INTERNET")
AddPermission("android.permission.WRITE_EXTERNAL_STORAGE")
AddPermission("android.permission.SEND_SMS")
AddPermission("android.permission.SEND_MMS")
AddPermission("android.permission.READ_CONTACTS")
addpermission("android.permission.RECEIVE_SMS")
AddPermission("android.permission.WRITE_CONTACTS") 'if write access is required

SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
AddActivityText(Main,
<!-- Activity that allows the user to send new SMS/MMS messages -->
<activity android:name=".ComposeSmsActivity" >
<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>)
 

tekh2999

Member
Licensed User
Longtime User
Right the intent is not relavent I saw it and put it in at the last moment out of desperation hoping something will happen, this is existing code (http://www.b4x.com/android/forum/threads/send-an-mms-using-b4a-question.16360/page-2#post-228080), but no matter what I do I can't get none of them to work, I even have the MMS lib library and can't get that to operate is thier a better approach, what I'm trying to do is I have a button, that sends a Text message to another phone with attachment, nothing fancy, now I have this code that works great but no attacthment, been reading online different ideas and none so far have worked. I have a old Huawei Mercury that so far has done everything I've asked of it app-wise but this. I have old B4A version 2.71 been wanting to upgrade soon but if I can't get this working which it vital to allot of the apps i want to create, Can you help?

this code works but no Attatchment:
B4X:
  dim share As Intent

share.Initialize("android.intent.action.SEND_MSG",  EditText4.Text) 'phone number
  share.setType("vnd.android-dir/mms-sms")
  share.PutExtra("android.intent.extra.STREAM", CreateUri("file://" & File.Combine(File.DirRootExternal, "FI1.JPEG")))
  share.PutExtra ("address", EditText4.Text)
  share.PutExtra ("sms_body", "Hello!!")

  share.SetComponent("com.android.mms/.ui.ComposeMessageActivity")
  share.SetType("image/JPEG")

    Message.setFileToAdd (File.DirRootExternal,"FI1.JPEG")
    StartActivity(share)
  End If
Message.Initialize ("MESSAGE",True)
 
Upvote 0

tekh2999

Member
Licensed User
Longtime User
It is highly possible that the SMS app doesn't support attachments through intents. You need to find Java code that does it and then post that code.
Thank you, That is something I've been looking into as well as last resort, I'm sure it exits there anyway. Do I have to learn java to make this work since I only know VB? is it that complicated? I just want to send some of my artwork to some friends my own app.
 
Upvote 0

tekh2999

Member
Licensed User
Longtime User
Ok thank you Earl, I believe i know where one is, I'll grab it and try it out again to get it to work. Ill let you know ltr on the results.
 
Upvote 0
Top