我正在尝试将图像文件保存到外部存储.我可以将图片保存到SD卡,但它不会出现在Androids gallery应用程序中.我尝试过这种方法:
File path = Environment.getExternalStorageDirectory();
File f = new File(path + "/mydirectory/" + imageName + "_" + System.currentTimeMillis() + ".jpg");
FileOutputStream fos = new FileOutputStream(f);
f.mkdirs();
b.compress(CompressFormat.JPEG, 100, fos);
fos.close();
Uri contentUri = Uri.fromFile(f);
Intent mediaScanIntent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
mediaScanIntent.setData(contentUri);
getApplicationContext().sendBroadcast(mediaScanIntent);
Run Code Online (Sandbox Code Playgroud)
但它没有出现在画廊中.谁能指出我正确的方向来解决这个问题?
可能重复:
从字符串中获取URL
嗨,我试图使用regexp从字符串中提取url.字符串类似于:"lorem ipsum baby www.test.com lorem","lorem ipsum http://www.test.com foo bar"或"lorem www.test.com",没有尾随空格.
using
MatchCollection ms = Regex.Matches(adress, @"(www.+|http.+)([\s]|$)");
返回整个字符串.任何regexp-guru能帮助我解决这个问题吗?
编辑:
解决这个问题:
MatchCollection mc = Regex.Matches(adress, @"(www[^ \s]+|http[^ \s]+)([\s]|$)", RegexOptions.IgnoreCase);
adress = mc[0].Value;
WebBrowserTask task = new WebBrowserTask();
task.URL = adress;
task.Show();
感谢大家的帮助!:)