是否有可能从 foreachline 中断。我的代码:
fun test() {
bufferedReader.forEachLine {
val nameParam = it.split(":")[0]
if (name == "test")
return // here i wan to return from function
}
}
Run Code Online (Sandbox Code Playgroud)
我试过“return@foreachline”,但它只是继续到下一行
我最近更新了我的应用程序,以支持android 6 marshmallow.我按照https://developer.android.com/training/permissions/requesting.html上的说明进行操作
并为Manifest.permission.RECEIVE_SMS添加了requestPermissions.当我运行以下代码时:
Log.i(TAG, "sending SMS...");
Intent intent = new Intent("android.provider.Telephony.SMS_RECEIVED");
intent.putExtra("pdus", data);
getContext().sendOrderedBroadcast(intent, null);
Run Code Online (Sandbox Code Playgroud)
我明白了
java.lang.SecurityException:Permission Denial:不允许从pid = 1999发送广播android.provider.Telephony.SMS_RECEIVED,uid = 10056
即使我授予SMS_RECEIVED权限,我也无法在设备上发送短信广播.
任何想法为什么我在Android 6上获得此安全异常.
我的目标是在我的设备链接中生成假短信[ 我可以发送"短信接收意图"吗? .我没有在谷歌上发现任何提及它不再允许.