enter image description here this is the Exception!
These are codes!This is not certain happen,in service,log display of the devices are samsung,and system is greater than android 6.0. I don't know the reasons,Could you help me,Thanks guys
public static void share(Context context, String packageName, String path, String content) {
Intent intent = new Intent(Intent.ACTION_SEND);
if (TextUtils.isEmpty(path)) {
intent.setType("text/plain"); //
} else {
File file = new File(path);
if (file.exists() && file.isFile()) {
intent.setType("image/*");
Uri uri = Uri.fromFile(file);
intent.putExtra(Intent.EXTRA_STREAM, uri);
}
}
intent.putExtra(Intent.EXTRA_TEXT, content);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (!TextUtils.isEmpty(packageName)) {
intent.setPackage(packageName);
context.startActivity(intent);
return;
}
context.startActivity(Intent.createChooser(intent, ""));
}