Java 我的代码很好,但有问题,因为android模拟器
我从香奈儿那里读到的文件,代码运行良好,但在应用程序中添加了更多功能之后Java 我的代码很好,但有问题,因为android模拟器,java,android,multithreading,Java,Android,Multithreading,我从香奈儿那里读到的文件,代码运行良好,但在应用程序中添加了更多功能之后 05-11 09:23:53.339: E/ThrottleService(300): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENO
05-11 09:23:53.339: E/ThrottleService(300): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file or directory)
05-11 09:24:05.699: D/dalvikvm(300): GC_CONCURRENT freed 584K, 63% free 4903K/13000K, paused 99ms+56ms, total 569ms
我已经搜索了这个问题,但没有得到足够的信息来解决这个问题。我在下面的代码中遇到了这个问题。我正在asyntask中运行此代码
public class screencahnge extends AsyncTask < String, Bitmap, Bitmap > {
ImageView im2 = null;
Bitmap b = null;
int ch = 0;
boolean flag = true;
public screencahnge(ImageView im) {
im2 = im;
}
@Override
protected Bitmap doInBackground(String...arg0) {
// TODO Auto-generated method stub'
// Runtime.getRuntime().availableProcessors();
if (RemoteScreen.out == null) {
System.out.print("Its null dude");
}
try {
RemoteScreen.out.write(210);
//Home.threadloop = false;
b = fileReceived(RemoteScreen. in );
publishProgress(b);
b = null;
ch = 4646;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onProgressUpdate(Bitmap...images) {
if (images[0] != null)
im2.setImageBitmap(images[0]);
images = null;
b.recycle();
doInBackground("");
System.gc();
}
protected void onPostExecute(Void unused) {
b.recycle();
}
public Bitmap fileReceived(InputStream is)
throws FileNotFoundException, IOException {
Bitmap bitmap = null;
String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
String fileName = "a.png";
String imageInSD = baseDir + File.separator + fileName;
System.out.println(imageInSD);
if (is != null) {
FileOutputStream fos = null;
BufferedOutputStream bos = null;
try {
// Log.i("IMSERVICE", "FILERECCC-1");
//ContextWrapper context = null;
fos = new FileOutputStream(imageInSD);
bos = new BufferedOutputStream(fos);
byte[] aByte = new byte[1024];
int bytesRead;
while ((bytesRead = is.read(aByte)) > 0) {
if (bytesRead == 1)
break;
bos.write(aByte, 0, bytesRead);
System.out.println("Loop" + aByte);
}
bos.close();
System.out.println("Loop out");
java.io.FileInputStream in = new FileInputStream(imageInSD);
bitmap = BitmapFactory.decodeStream( in );
bitmap = BitmapFactory.decodeFile(imageInSD);
Log.i("IMSERVICE", "saved");
if (bitmap != null)
System.out.println(bitmap.toString());
} catch (IOException ex) {
// Do exception handling
// Log.i("IMSERVICE", "exception ");
}
}
return bitmap;
}
}
public-class-screencahnge扩展异步任务{
ImageView im2=null;
位图b=null;
int ch=0;
布尔标志=真;
公共屏幕(ImageView im){
im2=im;
}
@凌驾
受保护位图doInBackground(字符串…arg0){
//TODO自动生成的方法存根'
//Runtime.getRuntime().availableProcessors();
if(RemoteScreen.out==null){
System.out.print(“它的null dude”);
}
试一试{
RemoteScreen.out.write(210);
//Home.threadloop=false;
b=文件接收(RemoteScreen.in);
出版进度(b);
b=零;
ch=4646;
}捕获(IOE异常){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
返回null;
}
@凌驾
受保护的void onProgressUpdate(位图…图像){
如果(图像[0]!=null)
im2.setImageBitmap(图像[0]);
图像=空;
b、 回收();
doInBackground(“”);
gc();
}
受保护的void onPostExecute(未使用的void){
b、 回收();
}
已接收公共位图文件(InputStream为)
抛出FileNotFoundException,IOException{
位图=空;
字符串baseDir=Environment.getExternalStorageDirectory().getAbsolutePath();
字符串fileName=“a.png”;
字符串imageInSD=baseDir+File.separator+fileName;
系统输出打印项次(imageInSD);
如果(is!=null){
FileOutputStream=null;
BufferedOutputStream bos=null;
试一试{
//Log.i(“IMSERVICE”、“FILERECCC-1”);
//ContextWrapper context=null;
fos=新文件输出流(imageInSD);
bos=新的缓冲输出流(fos);
字节[]aByte=新字节[1024];
int字节读取;
而((bytesRead=is.read(aByte))>0){
如果(字节读==1)
打破
bos.write(aByte,0,bytesRead);
System.out.println(“循环”+aByte);
}
bos.close();
System.out.println(“循环输出”);
java.io.FileInputStream in=新的FileInputStream(imageInSD);
位图=BitmapFactory.decodeStream(in);
位图=BitmapFactory.decodeFile(imageInSD);
Log.i(“IMSERVICE”、“saved”);
if(位图!=null)
System.out.println(bitmap.toString());
}捕获(IOEX异常){
//执行异常处理
//Log.i(“IMSERVICE”、“exception”);
}
}
返回位图;
}
}
此代码从频道读取图像并设置为imageview,此代码以前对我来说运行良好,但现在我在这个应用程序中使用此代码时遇到了此问题。我尝试了许多解决方案。我创建了新的模拟器,并在该模拟器上进行了测试。我检查了所有必需的权限。我添加了internet权限、网络状态权限等
提前谢谢