Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9198759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:21:48+00:00 2026-06-17T22:21:48+00:00

I am creating an android app drawer, but it fails when i call the

  • 0

I am creating an android app drawer, but it fails when i call the activity. Seems like it’s something wrong on line 39.
It looks something like a NullPointerException.
Could you please help me?

Java code:

package com.mysoftware.mysoftwareos.mobile;

import java.util.ArrayList;

import android.app.ListActivity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

public class AllAppsActivity extends ListActivity {
LinearLayout appsLinearLayout;
ListView list;
Intent intent;
private ArrayList<ResolveInfo> mApplicationList;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.allapps_screen);
    //Import views
    appsLinearLayout = (LinearLayout)findViewById(R.id.appsLinearLayout);

    //Set wallpaper
    appsLinearLayout.setBackgroundResource(R.drawable.images);

    //Load all apps
    final PackageManager pm = this.getPackageManager();

    final ArrayList<ResolveInfo> list =
            (ArrayList<ResolveInfo>) pm.queryIntentActivities(intent, 
                    PackageManager.PERMISSION_GRANTED);
    for (ResolveInfo rInfo : list)
    {

        Log.i("TAG", ": Installed Applications " + rInfo.activityInfo.
                applicationInfo.loadLabel(pm).toString());
    }

    final ArrayAdapter<ResolveInfo> adapter = 
        new ArrayAdapter<ResolveInfo>(this, android.R.layout.simple_list_item_1, list)
        {
            @Override
            public View getView(int position, View convertView, ViewGroup parent)
            {
                convertView = super.getView(position, convertView, parent);
                final String text = list.get(position).activityInfo.
                    applicationInfo.loadLabel(pm).toString();
                ((TextView)convertView).setText(text);
                return convertView;
            }
        };
    setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    final Intent intent = new Intent(Intent.ACTION_MAIN);
    final ActivityInfo info = mApplicationList.get(position).activityInfo;
    intent.setClassName(info.packageName, info.name);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    startActivity(intent);
}
}

Xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/appsLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >


<TextView
    android:id="@+id/TextView03"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Apps"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textSize="35dp" />


<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

</ListView>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="35dp"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/ImageView03"
        android:layout_width="match_parent"
        android:layout_height="13dp"
        android:scaleType="fitXY"
        android:src="@drawable/seperator" />
</LinearLayout>

</LinearLayout>

Logcat:

01-27 01:35:24.610: E/AndroidRuntime(2150): FATAL EXCEPTION: main
01-27 01:35:24.610: E/AndroidRuntime(2150): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mysoftware.mysoftwareos.mobile/com.mysoftware.mysoftwareos.mobile.AllAppsActivity}: java.lang.NullPointerException
01-27 01:35:24.610: E/AndroidRuntime(2150):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1968)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at  android.app.ActivityThread.access$600(ActivityThread.java:127)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at android.os.Looper.loop(Looper.java:137)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at android.app.ActivityThread.main(ActivityThread.java:4499)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at java.lang.reflect.Method.invokeNative(Native Method)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at java.lang.reflect.Method.invoke(Method.java:511)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at dalvik.system.NativeStart.main(Native Method)
01-27 01:35:24.610: E/AndroidRuntime(2150): Caused by: java.lang.NullPointerException
01-27 01:35:24.610: E/AndroidRuntime(2150):     at android.app.ApplicationPackageManager.queryIntentActivities(ApplicationPackageManager.java:440)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at com.mysoftware.mysoftwareos.mobile.AllAppsActivity.onCreate(AllAppsActivity.java:39)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at android.app.Activity.performCreate(Activity.java:4637)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1051)
01-27 01:35:24.610: E/AndroidRuntime(2150):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
01-27 01:35:24.610: E/AndroidRuntime(2150):     ... 11 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:21:50+00:00Added an answer on June 17, 2026 at 10:21 pm

    From what I can see, from this:

    final ArrayList<ResolveInfo> list =
                (ArrayList<ResolveInfo>) pm.queryIntentActivities(intent, 
                        PackageManager.PERMISSION_GRANTED);
    

    intent is still null, you haven’t made an Intent Object.

    I’m not sure what Intent you’re trying to match against, but you still need to instantiate it using the new keyword before using it.

    Eg

    intent = new Intent (Intent.ACTION_MAIN);
    

    Also from that same call, you are shadowing the global variable list. Either consider taking out

    final ArrayList<ResolveInfo>
    

    so you are working with the global list or remove that global reference.

    Moving on, I don’t thik PackageManager.PERMISSION_GRANTED is a valid flag for this method, since this seems to be a result constant.

    Lastly: mApplicationList is also not instantiated, but then you try to read from it. Now this may be set somewhere else, we don’t have the whole code. This only affects the click on a List item.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating my first android app. It seems fairly simple. But I'm a total
I am creating an app on android but after hearing about sencha that it
I am creating lists in my android app and would like to capture the
I'm creating android app that has table layout for the main activity, and that
I am creating an Android app and would like to provide several layouts that
I'm creating an android app which will call a method which parses the selected
I've created an android app and added admob ads to it. but while creating
Suppose I am creating an Android application that's like an SMS app. The requirements
I'm creating an Android app which must do some web surfing in the background
I am creating an android app myself (min sdk version 7 or 2.1 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.