0

String message = "HELLO MSM";

    Uri sendSmsTo = Uri.parse("smsto:" + "1111");

    Intent intent = new Intent(android.content.Intent.ACTION_SENDTO,
            sendSmsTo);
    intent.putExtra("sms_body", message);
    intent.putExtra(Intent.EXTRA_STREAM,
            Uri.parse(wallpaperDirectory.getPath() + "/nmc.jpg")); // url

    // intent.setType("audio/mp3");
    intent.setType("image/png");
    startActivity(intent);

But when run , app was FC

02-24 21:56:09.881 E 8333 AndroidRuntime Process: com.example.a, PID: 8333 02-24 21:56:09.881 E 8333 AndroidRuntime android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SENDTO typ=image/jpg (has extras) }

Please help me check ! Thank you !

1 Answers1

0

There is no activity that supports ACTION_SENDTO with a MIME type of image/jpg on your device.

Note that the MIME type for JPEG is image/jpeg.

But, beyond that, there is no requirement for every one of the ~1.5 billion Android devices to have an app that will handle your request. You need to either handle this exception or use PackageManager to check ahead of time whether your request will succeed.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491