Java android show toast

Toast testToast = Toast.makeText(this, "Your Message Here", Toast.LENGTH_LONG); testToast.show();Toast testToast = Toast.makeText(this, "Your Message Here", Toast.LENGTH_LONG); testToast.show();

Android java close app

@Override public void onBackPressed() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle("Do You Want To Exit From Application?"); alertDialogBuilder .setMessage("Click Yes to exit!") .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { moveTaskToBack(true); android.os.Process.killProcess(android.os.Process.myPid()); System.exit(1); } })   .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) {   dialog.cancel(); } }); … Read more

Android glide dependency

dependencies { implementation ‘com.github.bumptech.glide:glide:4.11.0’ annotationProcessor ‘com.github.bumptech.glide:compiler:4.11.0’ }dependencies { implementation ‘com.github.bumptech.glide:glide:4.11.0’ annotationProcessor ‘com.github.bumptech.glide:compiler:4.11.0’ }

Android get screen width and height

DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); float displayHeight = displayMetrics.heightPixels / displayMetrics.density; float displayWidth = displayMetrics.widthPixels / displayMetrics.density; Log.d("Display Height", displayHeight +""); Log.d("Display Width", displayWidth +"");DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); float displayHeight = displayMetrics.heightPixels / displayMetrics.density; float displayWidth = displayMetrics.widthPixels / displayMetrics.density; Log.d("Display Height", displayHeight +""); Log.d("Display Width", displayWidth +"");

Spigot broadcast message

Bukkit.getServer().broadcastMessage("Write Your message here.");Bukkit.getServer().broadcastMessage("Write Your message here.");

Check if recyclerview is empty

if (recyclerview.getItemCount() == 0) { Toast.makeText(getActivity(), "No records to show!", Toast.LENGTH_SHORT).show(); }if (recyclerview.getItemCount() == 0) { Toast.makeText(getActivity(), "No records to show!", Toast.LENGTH_SHORT).show(); }

Current date in android studio

Android java set current Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String strDate = sdf.format(c.getTime()); Log.d("Date","DATE : " + strDate)Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String strDate = sdf.format(c.getTime()); Log.d("Date","DATE : " + strDate) Android java get current import java.time.*; LocalDate date = LocalDate.now();import java.time.*; LocalDate date = … Read more

Androidx recyclerview dependency

dependencies { implementation "androidx.recyclerview:recyclerview:1.1.0" // For control over item selection of both touch and mouse driven selection implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc01" }dependencies { implementation "androidx.recyclerview:recyclerview:1.1.0" // For control over item selection of both touch and mouse driven selection implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc01" }