Ich habe das Bild zu erfassen und zu dem server.My Code speichere manchmal Fehler bekommen, während bei anderen mobilen versions.In Lollipop Überprüfung Störung erhalten as-Fehlererfassung Bild in verschiedenen Android-Versionen in android
nicht in der Lage Stream zu dekodieren: java.lang.NullPointerException: Versuch virtuelle Methode aufzuzurufen 'char [] java.lang.String.toCharArray()' auf einer null Objektreferenz
In anderem Mobile eRROR-
immerandroid Bitmap Fabrik nicht in der Lage Strom
cameraButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
takePhoto();
}
});
public void dispatchTakePictureIntent() {
Log.e("CREATED PHOTO", "photo pathS = ");
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent
.resolveActivity(getApplicationContext().getPackageManager()) != null) {
// Create the File where the photo should go
try {
photoFile = createImageFile();
Log.e("photoFile", "" + photoFile);
} catch (IOException ex) {
// Error occurred while creating the File
}
// Continue only if the File was successfully created
if (photoFile != null) {
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photoFile));
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
Log.i(TAG, "onActivityResult: " + this);
try {
if (requestCode == REQUEST_TAKE_PHOTO
&& resultCode == Activity.RESULT_OK) {
try {
setPic();
new Myfile().execute();
imagesPath1=mCurrentPhotoPath;
}catch (Exception e)
{
e.printStackTrace();
}
}
private void setPic() {
try {
Log.e("SETPIC",
"photo path SETPIC = ");
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
Log.i("", "" + mCurrentPhotoPath);
BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
int photoW = bmOptions.outWidth;
int photoH = bmOptions.outHeight;
// Decode the image file into a Bitmap sized to fill the View
bmOptions.inJustDecodeBounds = false;
bmOptions.inPurgeable = true;
Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
Matrix mtx = new Matrix();
mtx.postRotate(90);
Bitmap rotatedBMP = Bitmap.createBitmap(bitmap, 0, 0,
bitmap.getWidth(), bitmap.getHeight(), mtx, true);
rotatedBMP.recycle();
if (rotatedBMP != bitmap)
bitmap.recycle();
try {
sendPhoto(rotatedBMP);
} catch (Exception e) {
e.printStackTrace();
}
}catch(Exception e)
{
e.printStackTrace();
}
}
class Myfile extends AsyncTask<Void, Void, Void> {
// ProgressDialog progress;
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
mProgressDialog = new ProgressDialog(Events_Edit.this);
mProgressDialog.setMessage("Loading...");
mProgressDialog.setIndeterminate(false);
mProgressDialog.setCancelable(false);
mProgressDialog.show();
}
@Override
protected Void doInBackground(Void... params) {
try {
if (imagesPathList != null) {
if (imagesPathList.size() >= 1) {
for (int i = 0; i < imagesPath.length; i++) {
strImg = imagesPath[i];
File f = new File("" + strImg);
String path = f.getName();
URL_PATH = URL + path;
doFileUpload(f);
}
Log.d("",
"no of image are selected" + imagesPathList.size());
} else {
Log.d("",
"no of image are selected" + imagesPathList.size());
}
} else if (!imagesPath1.equalsIgnoreCase("")) {
File f = new File("" + imagesPath1);
String path = f.getName();
URL_PATH = URL + path;
Log.e("File", "" + f);
doFileUpload(f);
//}
}
}catch (Exception e)
{
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
if (mProgressDialog.isShowing())
{
mProgressDialog.dismiss();
}
if(URL_PATH!=null){
upload_edit.setText("Image Added");
upload_edit.setTextColor(Color.GREEN);
}
}
}
public void doFileUpload(File f) {
FTPClient client = new FTPClient();
try {
client.connect(FTP_HOST, 21);
Log.e("clientconnect", "" + client);
client.login(FTP_USER, FTP_PASS);
Log.e("clientlogin", "" + client);
client.setType(FTPClient.TYPE_BINARY);
Log.e("clienttype", "" + client);
client.changeDirectory("/abc/");
client.upload(f, new MyTransferListener());
Log.e("filenameupload", "" + f);
Log.e("clientupload", "" + client);
} catch (Exception e) {
e.printStackTrace();
try {
client.disconnect(true);
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
Constants.photoFile = Common.createImageFile() - nicht – user5826068
ersetzen unterstützt mit diesem 'Photofile = createImageFile();' auch in folgenden Zeile dieses 'Constants.photoFile' zu' photoFile' –
@ user5826068 ist Ihr Problem Fest? –