Android Bitmap OOM防止その他の操作


OOM防止、すなわちBitmapピクチャの圧縮
//       
	public Bitmap reBitmap(String path) {

		BitmapFactory.Options options = new BitmapFactory.Options();
		options.inJustDecodeBounds = false;
		//          1/4
		options.inSampleSize = 4;
		Bitmap bitmap = BitmapFactory.decodeFile(path, options);
		return bitmap;

	}

ファイルの名前変更
File file1=new File(path);  
	File file2=new File(pastePath);  
	boolean flag = file1.renameTo(file2);

時間に基づいて時間に名前を付けた画像を選択
//       
	public ArrayList<String> GetFilePath(Long commitTime) {
		// File file_ = new File(isSdcard() + photoPath);
		File file_ = new File(photoPath);
		File[] files = file_.listFiles();
		ArrayList<String> myFilePath = new ArrayList<String>();
		if (files != null) {
			Log.v("Camera", "    ");
			int count = files.length;
			System.out.println(count);
			for (int i = 0; i < count; i++) {
				File file = files[i];
				String filepath = file.getAbsolutePath(); //     
				Log.v("  1---", filepath);
				
				// pathTime     ,              
				Long pathTime = Long.parseLong(filepath.substring(
						photoPath.length(), photoPath.length()
								+ commitTime.toString().length()));
				
				if (commitTime - pathTime <= 0) {

					if (filepath.endsWith("jpg") || filepath.endsWith("gif")
							|| filepath.endsWith("bmp")
							|| filepath.endsWith("png")) {

						//         
						
						myFilePath.add(filepath);
						Log.v("  3---", filepath);
						System.out.println("size is " + myFilePath.size());
					}

				}

			}
		}
		return myFilePath;
	}