Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
if(isSDPresent) {
// yes SD-card is present available
}
else {
// Sorry no sd card available
}
Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
if(isSDPresent) {
// yes SD-card is present available
}
else {
// Sorry no sd card available
}
long difference = date2.getTime() - date1.getTime();
days = (int) (difference / (1000*60*60*24));
hours = (int) ((difference - (1000*60*60*24*days)) / (1000*60*60));
min = (int) (difference - (1000*60*60*24*days) - (1000*60*60*hours)) / (1000*60);
private File file;After that convert to Drawable Image to Bitmap usein this two lines
Drawable myDrawable = getResources().getDrawable(R.drawable.logo);
Bitmap myLogo = ((BitmapDrawable) myDrawable).getBitmap();
After that call your method where we want "SaveImage_State" and give String name by defaultprivate String SaveImage_State(Bitmap finalBitmap, String name) {String root = Environment.getExternalStorageDirectory().toString() + "/pm";File myDir = new File(root);myDir.mkdirs();Random generator = new Random();int n = 10000;n = generator.nextInt(n);String fname = name + ".jpg";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();}return file.toString();}
AsyncTask<Void, Void, HttpEntity> editProfileTask = new AsyncTask<Void, Void, HttpEntity>() {
@Override
protected HttpEntity doInBackground(Void... params) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("Your url"); // your url
try {
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("firstname",new StringBody(firstnameEV.getText().toString(),
"text/plain",Charset.forName("UTF-8")));
"text/plain",Charset.forName("UTF-8")));
if (file != null) {
reqEntity.addPart("image",new FileBody(((File) file),"application/zip"));
}
httppost.setEntity(reqEntity);
HttpResponse resp = httpclient.execute(httppost);
HttpEntity resEntity = resp.getEntity();
return resEntity;
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}return null;
}
@Override
protected void onPostExecute(HttpEntity resEntity) {
if (resEntity != null) {
try {
JSONObject responseJsonObject = new JSONObject(EntityUtils.toString(resEntity));
String status = responseJsonObject.getString("status");
if (status.equals("success")) {
Toast.makeText(activity, "Your Profile is updated", Toast.LENGTH_LONG).show();
String data = responseJsonObject.getString("data");
isUpdatedSuccessfully=true;
} else {
Toast.makeText(activity, "Profile not updated", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
};
editProfileTask.execute(null, null, null);
<activity
android:name=".YourActivityName"
android:configChanges="orientation|screenSize">
</activity>
/* * This Method is for select range from picker. * */ private fun selectDateRangeUsingRangePicker () { pageNumber = 1 val displ...