关注这个问题,有没有办法在没有提示用户任何东西的情况下启动android的意图?
现在,我正在检索这样的图像:
public void changeImage(View view) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(
Intent.createChooser(intent, getResources().getString(R.string.select_picture)),
PICK_IMAGE);
}
Run Code Online (Sandbox Code Playgroud)
然后我存储Uri,并在必要时显示图像(我实际上首先调整它的大小,但这没关系):
Uri _uri = Uri.parse(_path);
InputStream imageStream = null;
try {
imageStream = getContentResolver().openInputStream(_uri);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Bitmap b = BitmapFactory.decodeStream(imageStream);
iv.setImageBitmap(b);
Run Code Online (Sandbox Code Playgroud)
我想通过"默默地"调用意图来获取给定其Uri的图像数据,以获得相关权限.所以我需要这样的东西:
编辑:
我试过这个setPackage()方法.此代码具有以下行为:
如果使用ACTION_VIEW意图,则会打开图库并显示特定图像.
如果使用了ACTION_GET_CONTENT意图,即使我提供了特定的Uri,也会提示我从图库中选择一个图像.
>
Uri _uri = Uri.parse(_path);
InputStream imageStream = null;
Bitmap b = null;
try {
imageStream = getContentResolver().openInputStream(_uri);
b = BitmapFactory.decodeStream(imageStream);
ImageView iv = (ImageView) findViewById(R.id.playerImage); …Run Code Online (Sandbox Code Playgroud) 我正在尝试向图库添加新图像.我通过意图选择一个已存在的图像然后调整大小并压缩它.
然后我存储结果位图:
public static File compressAndSaveImage(Context ctx, Uri imageUri) throws FileNotFoundException {
File file = null;
if (imageUri != null) {
ContextWrapper cw = new ContextWrapper(ctx);
File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
file = new File(directory, imageUri.getLastPathSegment());
System.out.println("storing to " + file);
InputStream input = ctx.getContentResolver().openInputStream(imageUri);
Bitmap b = ImageManager.resize(BitmapFactory.decodeStream(input),
ctx.getResources().getDimension(R.dimen.player_thumb_w),
ctx.getResources().getDimension(R.dimen.player_thumb_h));
FileOutputStream fos = new FileOutputStream(file);
if (b.compress(Bitmap.CompressFormat.PNG, 100, fos)) {
System.out.println("Compression success");// bmp is your Bitmap instance
}
addPictureToGallery(ctx, file);
}
return file;
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试将图像添加到图库时,我没有错误,并且没有添加图像.我尝试了以下两种方法:
private static void addPictureToGallery(Context …Run Code Online (Sandbox Code Playgroud) 我有一个网络,当我绘制它时,有许多重叠的节点.我想更改颜色的不透明度,以便在重叠时可以看到其他节点.例如,请参阅此视频:https://vimeo.com/52390053
我正在使用iGraph我的情节.这是一个简化的代码模糊:
net1 <- graph.data.frame(myedgelist, vertices=nodeslist, directed = TRUE)
g <- graph.adjacency(get.adjacency(net1))
V(g)$color <- nodeslist$colors #This is a set of specific colors corresponding to each node. They are in the format "skyblue3". (These plot correctly for me).
E(g)$color <-"gray"
plot.igraph(g)
Run Code Online (Sandbox Code Playgroud)
但是,我无法找到iGraph更改节点颜色不透明度的选项.
知道怎么做这个吗?我想也许是这样的V(g)$alpha <- 0.8,但这没有做任何事情.
Access的VBA编辑器中使用的实际编码是什么?我一直在寻找一个具体的答案很久了,但是没有运气。
我以为是UTF-8,但我不太确定。
我的主要问题是,在VBA中编写查询时,有时需要在Access的查询编辑器中对其进行测试。但是,在复制粘贴时,我的本机字符(在我的情况下为希腊语)会丢失,因为它们变得乱码。
我曾尝试在文本编辑器中粘贴并将其另存为不同的编码,但是我永远无法恢复原始字符。
提前致谢。
编辑
让我进一步解释一下:
如您所见,我可以正常地在VBA编辑器中编写希腊字符:

但是,在Access的查询编辑器中复制第一行,我得到以下信息:

简单的文本编辑器也是如此:

因此,我倾向于认为问题出在剪贴板内部,这是由于用于希腊字符的编码所致。我猜它们不是Unicode,因为我确实必须在系统区域设置中更改非Unicode字符。那么如何保存/复制这些字符?用什么编码?
回答
实际上,在复制实际测试字符串时,通过将键盘输入语言切换为希腊语(EL)解决了该问题。
但是,我仍然不确定为什么会这样。如果有人可以对此提供一些见识,我很想听听。
再次感谢
我试图跳过浏览器提示以保存我的登录表单的密码.
我已经检查了这个问题,并添加了autocomplete ="off"属性(在表单和字段上).
只需导航到另一个页面就可以了.但是,当我使用?faces-redirect=true(在我的主页按钮)时,我得到提示.
admin.xhtml:
<h:form id="form" autocomplete="off">
<p:growl id="growl" showDetail="true" sticky="false" life="3000" />
<p:layout fullPage="true">
<p:layoutUnit position="center" >
<p:panel id="loginPanel" visible="#{not admin.loggedIn}">
<h:panelGrid columns="2" cellpadding="5">
<f:facet name="header">
<h:outputLabel value="Administration" />
</f:facet>
<h:outputLabel for="username" value="Username:" />
<p:inputText id="username" value="#{admin.username}" required="true" autocomplete="off" label="username" />
<h:outputLabel for="password" value="Password:" />
<p:password id="password" value="#{admin.password}" required="true" autocomplete="off" label="password" />
<f:facet name="footer">
<p:commandButton value="Login" update="growl loginPanel logoutPanel"
process="loginPanel" actionListener="#{admin.login}" />
</f:facet>
</h:panelGrid>
</p:panel>
</p:layoutUnit>
<p:layoutUnit position="north" size="85">
<p:panel id="logoutPanel">
<p:commandButton …Run Code Online (Sandbox Code Playgroud) 在这个问题及其答案之后,我正在创建一个应用程序,该应用程序给出一个密码字符串,将转换明文并将其密文、生成的盐和初始化向量存储在文本文件中。
在以下代码中:
public String decrypt(CryptGroup cp) throws Exception {
String plaintext = null;
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
KeySpec spec = new PBEKeySpec(password, cp.getSalt(), ITERATIONS, KEY_SIZE);
SecretKey secretKey = factory.generateSecret(spec);
SecretKeySpec secret = new SecretKeySpec(secretKey.getEncoded(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(cp.getIv()));
plaintext = new String(cipher.doFinal(cp.getCipher()), "UTF-8");
return plaintext;
}
public CryptGroup encrypt(String plainText) throws Exception {
byte[] salt = generateSalt();
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
KeySpec spec = new PBEKeySpec(password, salt, ITERATIONS, KEY_SIZE);
SecretKey secretKey = factory.generateSecret(spec); …Run Code Online (Sandbox Code Playgroud) 我安装了MongoDb windows server 2008 R2并且hotfix KB2731284没有安装,但我无法轻松重启服务器.
在hotfix描述中,我收到此消息"您运行的应用程序使用该FlushViewOfFile()函数从分页内存池中清除内存映射文件." (见https://support.microsoft.com/en-us/kb/2731284)
我的问题是,什么时候FlushViewOfFile()调用函数?我的应用程序只是写入一个集合并从中获取数据.我是否有冒险行为的风险?
所以我在C库中遇到了以下用于RF通信的代码:
#define __COMB(a,b,c) (a##b##c)
#define _COMB(a,b,c) __COMB(a,b,c)
Run Code Online (Sandbox Code Playgroud)
这基本上用于为常量和函数创建各种名称.它只是连接参数.
我没有得到的是第二行.是否有理由包装宏?如果这只是一个命名问题,为什么不写:
#define _COMB(a,b,c) (a##b##c)
Run Code Online (Sandbox Code Playgroud)
图书馆可以在这里找到.
提前致谢!
我们使用自定义注释实现了“之前”建议,以便仅在应用(对此问题不感兴趣)业务逻辑时执行某些方法。
我们看到该方法的每次调用都调用了两次方面。
调试它时,我看到Cglib2AopProxy$CglibMethodInvocation.proceed有一个名为:的数组 interceptorsAndDynamicMethodMatchers。该数组列出了PointCut ("RequiresX")两次。
这是连接点:
@Before(@annotation(requiresX)”)
public Object process(ProceedingJoinPoint joinPoint, RequiresACL requiresX) throws Throwable
{
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
log.info(" method:" + method.getName());
// do business logic of the aspect…
log.info(" joinPoint.proceed with call to " + method.getName());
}
Run Code Online (Sandbox Code Playgroud)
这是我们的自定义注释
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.Method)
public @interface RequiresX {
}
Run Code Online (Sandbox Code Playgroud)
这是我们可以拦截的方法:
@RequiresX()
public String someMethod() {
....
}
Run Code Online (Sandbox Code Playgroud)
这似乎很香草,但显然我做错了。任何关于如何在每次呼叫中仅执行一次建议的建议将不胜感激。