class GetApps {
public static List<Drawable> getApps(Activity activity) {
List<Drawable> result = new ArrayList<>();
PackageManager packageManager = activity.getPackageManager();
List<ApplicationInfo> listOfAppInfo = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo applicationInfo : listOfAppInfo) {
// this is our app
if (applicationInfo.packageName.equals(activity.getPackageName())) continue;
// this is system app
if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) continue;
result.add(packageManager.getApplicationIcon(applicationInfo));
}
return result;
}
}
public class Main extends Activity {
public void main() {
//это лишь пример вызова, вызов в твоём проекте осуществляться может в любом месте, в activity!
List<Drawable> result = GetApps.getApps(this);
}
}
lastCarpetId { value ->
//value получен
}
fun lastCarpetId(callback: (String) -> Unit) {
val db: FirebaseFirestore = FirebaseFirestore.getInstance()
db.collection("carpets")
.orderBy("carpetid")
.limit(1)
.get()
.addOnCompleteListener {
if (it.isSuccessful) {
for (document in it.result!!) {
callback(document.data.getValue("carpetid"))
}
}
}
}
val reasonEditText = EditText(requireContext())
reasonEditText.setBackgroundDrawable(requireContext().getDrawable(R.drawable.bg_edittext))
val dialog = AlertDialog.Builder(requireContext(), R.style.AlertTheme)
.setTitle("Причина приостановки подписки")
.setView(reasonEditText)
.setCancelable(true)
.setPositiveButton("Ок") { dialog, _ ->
dialog.cancel()
}
.setNegativeButton("Отмена") { dialog, _ ->
dialog.cancel()
}
.create()
dialog.show()
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
</shape>
</item>
<item
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/error_red" />
</shape>
</item>
</layer-list>