关于java–如何通过messenger从app发送图像?和messenger如何发送文件的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于android–如何通过java编码删除复选框的按
关于java – 如何通过messenger从app发送图像?和messenger如何发送文件的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于android – 如何通过java编码删除复选框的按钮图像?、exchange-2010 – 如何通过Microsoft.Exchange.Rpc.ClientAccess.Service.exe调查持续的高CPU使用率?、java – 使用ImageIO发送图像流?、java – 如何通过spring 4 resttemplate发送收到的jsessionid等相关知识的信息别忘了在本站进行查找喔。
本文目录一览:- java – 如何通过messenger从app发送图像?(messenger如何发送文件)
- android – 如何通过java编码删除复选框的按钮图像?
- exchange-2010 – 如何通过Microsoft.Exchange.Rpc.ClientAccess.Service.exe调查持续的高CPU使用率?
- java – 使用ImageIO发送图像流?
- java – 如何通过spring 4 resttemplate发送收到的jsessionid
java – 如何通过messenger从app发送图像?(messenger如何发送文件)
我想通过信使从我的应用程序发送图像.我正在寻找Stack Overflow,我发现answer适用于WhatsApp.当我尝试将“com.whatsapp”更改为“com.facebook.orca”时,它将停止工作.这是我的代码:
public void shareImageMessenger() {
Bitmap adv = BitmapFactory.decodeResource(getResources(), R.drawable.koza);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
adv.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory()
+ File.separator + "temporary_file_1.jpg");
try {
f.createNewFile();
new FileOutputStream(f).write(bytes.toByteArray());
} catch (IOException e) {
e.printstacktrace();
}
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse( Environment.getExternalStorageDirectory()+ File.separator+"temporary_file_1.jpg"));
share.setPackage("com.facebook.orca");
startActivity(Intent.createChooser(share, "Share Image"));
}
解决方法:
花了很多时间在这上面之后:
检查是否给出了权限.然后:
步骤1:在活动中创建您想要的图像的ImageView,然后将其转换为位图
ImageView imageView = findViewById(R.id.image);
Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
//save the image Now:
saveImage(bitmap);
//share it
send();
第2步:将图像存储在内部文件夹中:
private static void saveImage(Bitmap finalBitmap) {
String root = Environment.getExternalStorageDirectory().getAbsolutePath();
File myDir = new File(root + "/saved_images");
Log.i("Directory", "==" + myDir);
myDir.mkdirs();
String fname = "Image-test" + ".jpg";
File file = new File(myDir, fname);
if (file.exists()) file.delete();
try {
FileOutputStream out = new FileOutputStream(file);
finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
e.printstacktrace();
}
}
第3步:发送保存的图像:
public void send() {
try {
File myFile = new File("/storage/emulated/0/saved_images/Image-test.jpg");
MimeTypeMap mime = MimeTypeMap.getSingleton();
String ext = myFile.getName().substring(myFile.getName().lastIndexOf(".") + 1);
String type = mime.getMimeTypeFromExtension(ext);
Intent sharingIntent = new Intent("android.intent.action.SEND");
sharingIntent.setType(type);
sharingIntent.putExtra("android.intent.extra.STREAM", Uri.fromFile(myFile));
startActivity(Intent.createChooser(sharingIntent, "Share using"));
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
现在发送后,如果您不想将其保存在存储中,则可以删除已保存的图像.检查其他链接即可.
android – 如何通过java编码删除复选框的按钮图像?
<CheckBox android:layout_width="wrap_content" android:layout_height="25dp" android:button="@null" android:background="@drawable/notxtcheckBoxbtn" android:layout_weight="1"/>
但我需要在我的java代码中添加复选框.并且“newCheckBox.setButtonDrawable(null);”不起作用!
有谁知道如何在java代码中删除它?提前致谢!!!
解决方法
否则,如果要隐藏按钮并禁用它,可以使用set visibility()并将其设置为不可见或不可见.
exchange-2010 – 如何通过Microsoft.Exchange.Rpc.ClientAccess.Service.exe调查持续的高CPU使用率?
How should I investigate what is causing this increase?
以下是图表:
>六(6)台CAS服务器,在RPC / HTTPS(任何地方可用)模式下为3,000名用户提供服务.
> Windows 2008 R2
>最近升级到Exchange 2010 SP1 RU6(在RU3上的行为相同)
>每个CAS服务器都有四(4)个虚拟cpu
兴趣点
>由于我们要求最终用户针对不同的URL配置Activesync,我们在负载均衡器上设置了专用VIP,并隔离了底部的两个CAS服务器.这样做很容易……我们更改了公共DNS条目以便于隔离. (我希望MSFT最佳实践能够鼓励为Activesync部署提供隔离的URL)
>黑色的高cpu来自ActiveSync.
>绿色峰值来自RPC客户端访问服务.
我在服务器上运行了MSFT的DebugDiag,并且不知道这是否是正确的工具,或者如何处理一些更高级的结果.任何提示都表示赞赏.
java – 使用ImageIO发送图像流?
我有一个ServerSocket和一个Socket设置,所以ServerSocket使用ImageIO.write(….)发送图像流,Socket尝试读取它们并用它们更新JFrame.所以我想知道ImageIO是否可以检测到图像的结束. (我完全不了解JPEG格式,所以我测试了它)
显然不是.
在服务器端,我通过循环使用ImageIO.write(…)连续发送图像,其间有一些睡眠.在客户端,ImageIO读取第一个图像没问题,但在下一个图像上它返回null.这令人困惑.我期待它要么阻止阅读第一张图像(因为它认为下一张图像仍然是同一张图像的一部分),要么成功阅读所有这些图像(因为它有效).到底是怎么回事?它看起来像ImageIO检测到第一个图像的结束,但不是第二个图像的结束. (顺便说一下,这些图像大致相似)是否有一种简单的方法可以像这样流式传输图像,或者我是否必须创建自己的机制,将字节读入缓冲区,直到达到指定的字节或序列为止字节,此时它从缓冲区读取图像?
这是我的服务器代码的有用部分:
while(true){
Socket sock=s.accept();
System.out.println("Connection");
OutputStream out=sock.getoutputStream();
while(!socket.isClosed()){
BufferedImage img=//get image
ImageIO.write(img,"jpg",out);
Thread.sleep(100);
}
System.out.println("Closed");
}
我的客户代码:
Socket s=new Socket(InetAddress.getByName("localhost"),1998);
InputStream in=s.getInputStream();
while(!s.isClosed()){
BufferedImage img=ImageIO.read(in);
if(img==null)//this is what happens on the SECOND image
else // do something useful with the image
}
因此,理论上,您可以只获取ImageReader,自己创建一个ImageInputStream,并重复从ImageInputStream中读取ImageReader.
除此之外,看起来ImageInputStream设计用于处理一个且仅一个图像(可能包含或不包含多个帧).如果多次调用ImageReader.read(0),它将每次回退到(缓存的)流数据的开头,一遍又一遍地为您提供相同的图像. ImageReader.read(1)将在多帧图像中寻找第二帧,这当然对JPEG没有意义.
所以,也许我们可以创建一个ImageInputStream,让ImageReader从中读取,然后创建一个新的ImageInputStream来处理流中的后续图像数据,对吧?除此之外,看起来ImageInputStream会执行各种缓存,预读和后推,这使得很难知道包装的InputStream的读取位置.下一个ImageInputStream将开始从某个地方读取数据,但它并不像我们预期的那样位于第一个图像数据的末尾.
确定基础流的位置的唯一方法是使用标记和重置.由于图像可能很大,因此您可能需要BufferedInputStream来允许大型readLimit.
这对我有用:
private static final int MAX_IMAGE_SIZE = 50 * 1024 * 1024;
static void readImages(InputStream stream)
throws IOException {
stream = new BufferedInputStream(stream);
while (true) {
stream.mark(MAX_IMAGE_SIZE);
ImageInputStream imgStream =
ImageIO.createImageInputStream(stream);
IteratortimageReaders(imgStream);
if (!i.hasNext()) {
logger.log(Level.FINE,"No ImageReaders found,exiting.");
break;
}
ImageReader reader = i.next();
reader.setInput(imgStream);
BufferedImage image = reader.read(0);
if (image == null) {
logger.log(Level.FINE,"No more images to read,exiting.");
break;
}
logger.log(Level.INFO,"Read {0,number}\u00d7{1,number} image",new Object[] { image.getWidth(),image.getHeight() });
long bytesRead = imgStream.getStreamPosition();
stream.reset();
stream.skip(bytesRead);
}
}
java – 如何通过spring 4 resttemplate发送收到的jsessionid
我正在客户端站点上使用JavaFX和Spring4编写信使,在服务器站点上编写Spring4.我用spring-security 3.2保护了服务器.现在我的问题:我在客户端上有一个登录页面,将登录信息发送到spring-security并接收JSESSIONID cookie.这工作正常,但当我尝试用我的请求发送JSESSIONID时,我变成了一个
org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class org.messenger.rest.JSONConversationResult] and content type [text/html;charset=UTF-8]
服务器Inizializer
public class SpringMvcInitializer extends
AbstractAnnotationConfigdispatcherServletinitializer {
@Override
protected ClassfigClasses() {
return new Class[] {ApplicationConfig.class};
}
@Override
protected ClassfigClasses() {
return new Class[] {WebConfig.class};
}
@Override
protected String[] getServletMappings() {
return new String[] {"/"};
}
}
Server SecurityInizializer
public class SpringSecurityInitializer extends
AbstractSecurityWebApplicationInitializer {
}
Server SecurityConfig
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private DriverManagerDataSource dataSource;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
String authQuery = "select userid,authority from user where userid = ?";
String userQuery = "select userid,pw,enabled from user where userid = ?";
auth.jdbcAuthentication().dataSource(dataSource)
.passwordEncoder(passwordEncoder())
.usersByUsernameQuery(userQuery)
.authoritiesByUsernameQuery(authQuery);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/register").permitAll()
.antMatchers("/getconvs","/getcontacts").hasRole("USER")
.and()
.formLogin()
.and()
.csrf().disable();
}
@Bean
public AuthenticationEntryPoint authenticationEntryPoint() {
return new de.daschner.messenger.security.AuthenticationEntryPoint();
}
@Bean
public SuccessHandler successHandler() {
return new SuccessHandler();
}
@Bean
public SimpleUrlAuthenticationFailureHandler failureHandler() {
return new SimpleUrlAuthenticationFailureHandler();
}
@Bean
public AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager();
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder(11);
}
}
安全“页面”的服务器请求映射
@RequestMapping(value="/getconvs",method={RequestMethod.GET},produces={MediaType.APPLICATION_JSON_VALUE})
public @ResponseBody JSONConversationResult getConvsList(HttpServletRequest request,@RequestParam(value="uid") String uid){
JSONConversationResult ret = new JSONConversationResult();
Map
客户端发送登录并获取Cookie
Maphttpentity
客户端发送带有请求的JSESSIONID
ResponseEntity response = restTemplate.exchange(
" http:="" getconvs?uid=" + uid,HttpMethod.GET,getAuthHeader(),JSONConversationResult.class);
JSONConversationResult ret = response.getBody();
return ret;
private httpentityfig.getJsessionid());
return new httpentity
我希望你能帮助我.
编辑:
好的我发现问题不在于JSESSIONID没有正确发送.但我的登录不正确,我的查询从数据库中获取用户.
正确的登录帖子
ClientHttpResponse response = restTemplate.execute(
"http://localhost:8080/messenger-webapp/login",new RequestCallback() {
@Override
public void doWithRequest(ClientHttpRequest request) throws IOException {
request.getBody().write(("username=" + user + "&password=" + pw).getBytes());
}
},new ResponseExtractor
正确的查询
String authQuery = "select u.userid,r.role_name from user u,role r,user_role a where u.dbid = a.user_id and r.dbid = a.role_id and u.userid = ?";
我希望这会有助于其他人.如果有人有其他选择,请告诉我.
最佳答案
好的我发现问题不在于JSESSIONID没有正确发送.但我的登录不正确,请告诉我.
今天关于java – 如何通过messenger从app发送图像?和messenger如何发送文件的分享就到这里,希望大家有所收获,若想了解更多关于android – 如何通过java编码删除复选框的按钮图像?、exchange-2010 – 如何通过Microsoft.Exchange.Rpc.ClientAccess.Service.exe调查持续的高CPU使用率?、java – 使用ImageIO发送图像流?、java – 如何通过spring 4 resttemplate发送收到的jsessionid等相关知识,可以在本站进行查询。
本文标签: