• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Android Glide load saved drawable in variable

Hey all I have looped to gather game icons which I put them into a variable that is inside an class:
Java:
public class AndroidModel {
   private String name;
   private String title;
   private Drawable icon;
   Intent androidLaunch;

   public AndroidModel(String name, String title, Drawable _icon, Intent _launch) {
       this.name = name;
       this.title= title;
       this.icon = _icon;
       this.androidLaunch = _launch;
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }


   public void setTitle(String title) {
       this.title = title;
   }

   public String getTitle() {
       return title;
   }


   public void setIcon(Drawable icon) {
       this.icon = icon;
   }

   public Drawable getIcon() {return icon;}


   public void setLaunch(Drawable icon) {
       this.androidLaunch = androidLaunch;
   }

   public Intent getLaunch() {return androidLaunch;}
}
In my mainActivity:
Java:
class AppInfo {
   String appname = "";
   String pname = "";
   Drawable icon;
   String Source = "";
   Intent Launching;
}

AppInfo newInfo = new AppInfo();

newInfo.appname = activityInfo.applicationInfo.loadLabel(getContext().getPackageManager()).toString();
newInfo.pname = activityInfo.packageName;
newInfo.Source = activityInfo.applicationInfo.sourceDir;
newInfo.Launching = pm.getLaunchIntentForPackage(activityInfo.packageName);
newInfo.icon = activityInfo.applicationInfo.loadIcon(getContext().getPackageManager());

androidList.add(
   new AndroidModel(newInfo.appname, newInfo.appname, newInfo.icon, newInfo.Launching)
);
And I'm calling that back up once Glide populates that page by doing this:
Java:
@SuppressLint("UseCompatLoadingForDrawables")
@Override
public void onBindViewHolder(AndroidAdapter.MyViewHolder holder, int position) {
   ImageView imageView = holder.mPhotoImageView;

   if (!mAndroidList.get(position).getName().isEmpty()) {
       Glide.with(mContext)
               .asBitmap()
               .load(mAndroidList.get(position).getIcon())
               .diskCacheStrategy(DiskCacheStrategy.ALL)
               .skipMemoryCache(true)
               .priority(Priority.HIGH)
               .signature(new ObjectKey(String.valueOf(System.currentTimeMillis())))
               .apply(new RequestOptions().override(150, 150))
               .into(imageView);
       holder.mTitle.setText(mAndroidList.get(position).getName());
   }
}
But it seems to crash my app once it gets to the load(...) part. I know it has the app icon because I check it out using this:



and it came up just fine.

So what is it that I am missing in order to load these drawable variables into Glide?

LOG

2022-04-15 08:14:20.374 18885-18885/com.tutorialscache.tabslayout E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.tutorialscache.tabslayout, PID: 18885
java.lang.NullPointerException: Argument must not be null
at com.bumptech.glide.util.Preconditions.checkNotNull(Preconditions.java:29)
at com.bumptech.glide.util.Preconditions.checkNotNull(Preconditions.java:23)
at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:841)
at com.example.telluridetainment.adapter.AndroidAdapter.onBindViewHolder(AndroidAdapter.java:62)
at com.example.telluridetainment.adapter.AndroidAdapter.onBindViewHolder(AndroidAdapter.java:24)
at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6781)
at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6823)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5752)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6019)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
at androidx.recyclerview.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:557)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
at androidx.recyclerview.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:171)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4194)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at androidx.viewpager.widget.ViewPager.onLayout(ViewPager.java:1775)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:779)
at android.view.View.layout(View.java:21912)
2022-04-15 08:14:20.377 18885-18885/com.tutorialscache.tabslayout E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3080)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2590)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7598)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Cannot text or call any one with an Apple

Finally fixed.

It seems that Mr. Hacker was an Apple fan...... Once he/she/they "assumed control" of my phone number/account they had it placed into the Apple Imessage system or the like. Once I did the first hard reset it locked them out, but also locked me out of accessing any Apple devices......

After two+ days of SCREAMING at Verizon:
NO I DONT OWN AN APPLE !!!!
NO I DONT WANT TO PURCHASE AN APPLE PHONE !!

I bit the bullet for the umpteenth time and had my account closed and opened a whole new account and yet another phone number (with my full payment for) and viola, full usage of what I pay my provider for...


Please mark thread solved

Spyware/stalkerware?

Someone has been trying to break into my home so I have been recording videos. I noticed that sometimes the screen will get blurry and hard to see while recording then will clear back up mostly and I can see images of people and things that move but are transparent and not there when you look with your eyes. Does anyone know what's going on or how this is possible.
Just going by your description of the situation, this sounds more like to be a matter of the webcams you're using just can't do what you're expecting. This wouldn't be some kind of 'hack' issue nor a failure of the webcams themselves, it's just that a lot of consumer-level, off-the-shelf webcams have inherent limitations. The motion-detecting sensors and recording sensors are usually good in daylight situations but performance drops significantly at night, but it's typical for there to be a noticeable lag while the sensors try to assess what's detectable and the auto-focusing of the lens and/or aperture. If these are just common webcams, you'll need to upgrade to something more capable or reset your expectations on what they can provide. If these are however higher-grade webcams, there's likely to be sensor adjustment settings in the camera settings menu. (... which might be something to look into no matter what webcams you have). Most webcams have detection level options (i.e. really sensitive so even when a cat walks past will trigger auto-activating or not too much so only something like a vehicle passes by gets recorded.)

Hotspot

Why is there no hot spot on the LG 5 but the LG 4 had one? Grrrrrrr
so looks like the phone has the hotspot capabilities, but you need have the hotspot option in your plan. most carriers offer it for free, but on some you may have to pay extra for it.......so it will depend on your carrier as @Dannydet suggested. so i would either go in or give your carrier a call.

Pin Locked Galaxy S4 I545

Surely you'll have to unlock the phone before you can view files over USB?

Of course if the pictures are on the sd card it's easy: buy a USB card reader, put the sd card in it and plug it into the computer, then you'll be able to read the card like any other storage device. Or you can use another phone if you have one with a card slot. It's if they are in the phone's internal storage that you will need to remember the PIN.
normaly the samsung galaxy phone it is configured went connect to pc they activate mtn to transfer files to pc of course you only can see the phone internal storage

Convert solar lamp to electric?

I am glad you have your fairy light working too, I almost went up there, like a few days or so back to pick up some art supplies, I might consider o do like a different mediumn, maybe clay with a easel, and just have a pop up artwork, photograph it.. but what would the paint would look like underneath it? Hmmm... I too was thinking oddly enough of a fantasy type thing..

Extract data from .trace files (from the profiler in android studio) for visualization?

So, I have a few .trace (CPU performance) and .heapprofd (Memory usage) files that I exported from android studio profiler. However, I want to know is it possible to extract the performance timeline data from these files to visualize them externally (say using python)?

I understand these files contain a lot of information but I am only really interested in the overall CPU and memory consumption data. Also, if there is any other application that can allow me to export CPU performance and Memory consumption of my app in a more readable file, that works for me as well. All I want is to profile my app and visualize the performance externally (so I can customize the graph).

Any help will be highly appreciated. Thanks.

Can't show custom ProgressDialog

I have had this problem for several days.
I can't see my custom progress dialog optimally.

custom progress dialog layout:
Code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.cardview.widget.CardView
        android:layout_width="0dp"
        android:layout_height="183dp"
        android:layout_marginStart="16dp"
        android:layout_marginEnd="16dp"
        app:cardCornerRadius="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ProgressBar
                android:id="@+id/progressLoading"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.498"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/txtProgress" />

            <TextView
                android:id="@+id/txtProgress"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:text="Test..."
                android:textAlignment="center"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.495"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/txtProgressCount"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:text="TextView"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.501"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/progressBarCount"
                app:layout_constraintVertical_bias="1.0" />

            <ProgressBar
                android:id="@+id/progressBarCount"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.487"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/progressLoading" />


        </androidx.constraintlayout.widget.ConstraintLayout>


    </androidx.cardview.widget.CardView>

</androidx.constraintlayout.widget.ConstraintLayout>

class:

Java:
public class LoadingDialog{

    Context context;
    private Dialog dialog = null;
    public LoadingDialog(Context context) {
        this.context = context;
    }

    public void startLoadingDialog(String title) {
        dialog = new Dialog(context);
        dialog.setContentView(R.layout.custom_progressbar);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setCanceledOnTouchOutside(false);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        TextView txtTitleCount = dialog.findViewById(R.id.txtProgressCount);
        TextView txtTitle = dialog.findViewById(R.id.txtProgress);
        ProgressBar barCount = dialog.findViewById(R.id.progressBarCount);
        txtTitle.setText(title);
        txtTitleCount.setVisibility(View.GONE);
        barCount.setVisibility(View.GONE);
        dialog.setCancelable(false);
        dialog.create();
        dialog.show();


    }

    public void dismissDialog() {
        dialog.dismiss();
    }


}

Main (where I call the progress dialog):

Java:
final LoadingDialog loadingDialog = new LoadingDialog(this);

                ExecutorService service = Executors.newFixedThreadPool(10);
                service.execute(() -> {
                    runOnUiThread(() -> loadingDialog.startLoadingDialog("prova"));
                    SystemClock.sleep(1000);

                    runOnUiThread(loadingDialog::dismissDialog);

                });

the screen remains dark but is not presented in front of the dialog

Filter

Back
Top Bottom