#FinishActivityAnimation
Finish activity animation
finish();
overridePendingTransition( 0, 0);
startActivity(getIntent());
overridePendingTransition( 0, 0);
#KillProcces
kill procces
finishAffinity();
int pid = android.os.Process.myPid();
android.os.Process.killProcess(pid);
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
#ToastNew
Toast new ✓
LayoutInflater inflater = getLayoutInflater(); View toastLayout = inflater.inflate(R.layout.toast_animator, null);
Toast toast = new Toast(getApplicationContext()); toast.setDuration(Toast.LENGTH_LONG);
toast.setGravity(Gravity.TOP, 0,150);
TextView textview1 = (TextView) toastLayout.findViewById(R.id.textview1);
textview1.setText(_text);
LinearLayout linear1 = (LinearLayout) toastLayout.findViewById(R.id.linear1);
android.graphics.drawable.GradientDrawable gd = new android.graphics.drawable.GradientDrawable();
gd.setColor(Color.parseColor(_color1));
gd.setStroke((int)_size, Color.parseColor(_color2));
gd.setCornerRadius((int)_radius);
linear1.setBackground(gd);
ObjectAnimator anim = ObjectAnimator.ofFloat(linear1, "ScaleY", 0, 1);
anim.setDuration((int)_timer);
anim.start();
toast.setView(toastLayout);
toast.show();
#saveImageASaPicture
Save image as a picture
double y;
long t;
y = Math.random() * 1000000000;
t = (long)y * 108272622;
Bitmap returnedBitmap = Bitmap.createBitmap(_saveed.getWidth(), _saveed.getHeight(),Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(returnedBitmap);
android.graphics.drawable.Drawable bgDrawable =_saveed.getBackground();
if (bgDrawable!=null) {
bgDrawable.draw(canvas);
} else {
canvas.drawColor(Color.WHITE);
}
_saveed.draw(canvas);
java.io.File pictureFile = new java.io.File(Environment.getExternalStorageDirectory() + "/Download/" + t + ".png");
if (pictureFile == null) {
showMessage("Error creating media file, check storage permissions: ");
return; }
try {
java.io.FileOutputStream fos = new java.io.FileOutputStream(pictureFile); returnedBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
showMessage("Image Saved in /Download/ folder");
} catch (java.io.FileNotFoundException e) {
showMessage("File not found: " + e.getMessage()); } catch (java.io.IOException e) {
showMessage("Error accessing file: " + e.getMessage());
}
0 Comments