سؤال

I am working on a project where I need to send MMS from my android app. Below is the code which I tried but it is not working. Please advise.

Intent mmsIntent = new Intent(Intent.ACTION_SENDTO);
        mmsIntent.addCategory(Intent.CATEGORY_DEFAULT);
        mmsIntent.setType("vnd.android-dir/mms-sms");
        mmsIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));//Uri.parse(url));
        mmsIntent.setData(Uri.parse("sms:" + "89565656"));
        startActivity(mmsIntent);
هل كانت مفيدة؟

المحلول

check this:

Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra("address","9876543211");
i.putExtra("sms_body","hello..");
i.putExtra(Intent.EXTRA_STREAM,Uri);
i.setType("image/png");
startActivity(i);

Here Uri is:

 Uri uri = Uri.parse("content://media/external/images/media/1");

or

Uri uri = Uri.parse("file://mnt/sdcard/test.jpg");

or

Uri uri = Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/test.jpg");

نصائح أخرى

For me below code is working perfect.....

   Intent smsIntent = new Intent(android.content.Intent.ACTION_SEND);
            smsIntent.putExtra("sms_body", mContext.getString(R.string.app_name)); 
            smsIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://" + imagePath));
            smsIntent.setType("image/png");
            mContext.startActivity(smsIntent);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top