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 750481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:33:21+00:00 2026-05-14T14:33:21+00:00

I cant figure out why my program is showing null pointer exception. Plz help

  • 0

I cant figure out why my program is showing null pointer exception. Plz help me…Here’s the program…

public class MusicListActivity extends Activity {
List<HashMap<String, String>> songNodeDet = new ArrayList<HashMap<String,String>>();
HashMap<?,?>[] songNodeWeb; 
XMLRPCClient client;
String logInSess;
ArrayList<String> paths=new ArrayList<String>();
public ListAdapter adapter ;
Object[] websongListObject;
List<SongsList> SngList=new ArrayList<SongsList>();
Runnable r;
ProgressDialog p;
ListView lv;
String s;
@Override
public void onCreate(Bundle si){
    super.onCreate(si);
    setContentView(R.layout.openadiuofile);
    lv=(ListView)findViewById(R.id.list1);
    r=new Runnable(){
        public void run(){
            try{
                getSongs();
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (XMLRPCException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    };      
        Thread t=new Thread(r,"background");
        t.start();  
        Log.e("***","process over");
}
@Override
protected void onResume() {
    // TODO Auto-generated method stub
      super.onResume();

}
    private Runnable returnRes = new Runnable() {
    @Override
    public void run() { 
        Log.d("handler","handler");  
            removeDialog(0);
          p.dismiss();
          list();
        }                
        };
public void list()
{      Log.d("#####","#####");
 LayoutInflater inflater=getLayoutInflater();
 String[] from={};
 int[] n={};
 adapter=new SongsAdapter(getApplicationContext(),songNodeDet,R.layout.row,from,n,inflater);
 lv.setAdapter(adapter);}
private Handler handler = new Handler() {
    public void handleMessage(Message msg){
       Log.d("*****","handler");        
      removeDialog(0);
      p.dismiss();
     }
    }; 
 public void webObjectList(Object[] imgListObj,String logInSess) throws XMLRPCException{
    songNodeWeb = new HashMap<?,?>[imgListObj.length];
    if(imgListObj!=null){
        Log.e("completed","completed");
        for(int i=0;i<imgListObj.length;i++){ //imgListObj.length
        songNodeWeb[i]=(HashMap<?,?>)imgListObj[i];
        String nodeid=(String) songNodeWeb[i].get("nid");
        break;
        Log.e("img",i+"completed");
        HashMap<String,String> nData=new HashMap<String,String>();
        nData.put("nid",nodeid);        
        Object nodeget=client.call("node.get",logInSess,nodeid);
        HashMap<?,?> imgNode=(HashMap<?,?>)nodeget;
        String titleName=(String) imgNode.get("titles");
        String movieName=(String) imgNode.get("album");
        String singerName=(String) imgNode.get("artist");
        nData.put("titles", titleName);
        nData.put("album", movieName);
        nData.put("artist", singerName);
        Object[]  imgObject=(Object[])imgNode.get("field_image");
        HashMap<?,?>[] imgDetails=new HashMap<?,?>[imgObject.length];
        imgDetails[0]=(HashMap<?, ?>)imgObject[0];
        String path=(String) imgDetails[0].get("filepath");
        if(path.contains(" ")){
            path=path.replace(" ", "%20");
        }
         String imgPath="http://www.gorinka.com/"+path;
         paths.add(imgPath);
        nData.put("path", imgPath);
        Log.e("my path",path);
        String mime=(String)imgDetails[0].get("filemime");
        nData.put("mime", mime);
        SongsList songs=new SongsList(titleName,movieName,singerName,imgPath,imgPath);
        SngList.add(i,songs);
        songNodeDet.add(i,nData);
    }
    Log.e("paths values",paths.toString());     
//  return imgNodeDet;
    handler.sendEmptyMessage(0);
}
  }
    public void getSongs() throws MalformedURLException, XMLRPCException
{  
    String ur="http://www.gorinka.com/?q=services/xmlrpc";
    URL u=new URL(ur);
     client = new XMLRPCClient(u);      
    //Connecting to the website
    HashMap<?, ?> siteConn =(HashMap<?, ?>)  client.call("system.connect");
    // Getting initial sessio id
    String initSess=(String)siteConn.get("sessid");
    //Login to the site using session id        
    HashMap<?, ?> logInConn =(HashMap<?, ?>)  client.call("user.login",initSess,"prakash","stellentsoft2009");
    //Getting Login sessid
    logInSess=(String)logInConn.get("sessid");
    websongListObject =(Object[]) client.call("nodetype.get",logInSess,"");
     webObjectList(websongListObject,logInSess);
     Log.d("webObjectList","webObjectList");
     runOnUiThread(returnRes);
}

}

Here’s the Adapter associated…

public class SongsAdapter extends SimpleAdapter{
static List<HashMap<String,String>> songsList;
Context context;
LayoutInflater inflater;
public SongsAdapter(Context context,List<HashMap<String,String>> imgListWeb,int layout,String[] from,int[] to,LayoutInflater inflater) {
    super(context,songsList,layout,from,to);
    this.songsList=songsList;
    this.context=context;
    this.inflater=inflater;
    // TODO Auto-generated constructor stub
}
@Override
public View getView(int postition,View convertView,ViewGroup parent)throws java.lang.OutOfMemoryError{
    try {
    View v = ((LayoutInflater) inflater).inflate(R.layout.row,null);
    ImageView images=(ImageView)v.findViewById(R.id.image);
    TextView tvTitle=(TextView)v.findViewById(R.id.text1);
    TextView tvAlbum=(TextView)v.findViewById(R.id.text2);
    TextView tvArtist=(TextView)v.findViewById(R.id.text3);
    HashMap<String,String> songsHash=songsList.get(postition);
    String path=songsHash.get("path");
    String title=songsHash.get("title");
    String album=songsHash.get("album");
    String artist=songsHash.get("artist");
    String imgPath=path;    
    final ImageView imageView = (ImageView) v.findViewById(R.id.image);
    AsyncImageLoaderv asyncImageLoader=new AsyncImageLoaderv();
    Bitmap cachedImage = asyncImageLoader.loadDrawable(imgPath, new AsyncImageLoaderv.ImageCallback() {
        public void imageLoaded(Bitmap imageDrawable, String imageUrl) {
            imageView.setImageBitmap(imageDrawable);
        }
        });
    imageView.setImageBitmap(cachedImage);
    tvTitle.setText(title);
    tvAlbum.setText(album);
    tvArtist.setText(artist);
    return v;
    }
    catch(Exception e){
        Log.e("error",e.toString());
    }
    return null;
}
public static Bitmap loadImageFromUrl(String url) {
    InputStream inputStream;Bitmap b;
try {
    inputStream = (InputStream) new URL(url).getContent();
    BitmapFactory.Options bpo=  new BitmapFactory.Options();
    bpo.inSampleSize=2;
     b=BitmapFactory.decodeStream(inputStream, null,bpo );
     return b;
} catch (IOException e) {
        throw new RuntimeException(e);
    }
}

}

Here is what logcat is showing…

04-23 16:02:02.211: ERROR/completed(1450): completed
04-23 16:02:02.211: ERROR/paths values(1450): []
04-23 16:02:02.211: DEBUG/*****(1450): handler
04-23 16:02:02.211: DEBUG/AndroidRuntime(1450): Shutting down VM
04-23 16:02:02.211: WARN/dalvikvm(1450): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
04-23 16:02:02.222: ERROR/AndroidRuntime(1450): Uncaught handler: thread main exiting due to uncaught exception
04-23 16:02:02.241: DEBUG/webObjectList(1450): webObjectList
04-23 16:02:02.252: ERROR/AndroidRuntime(1450): java.lang.NullPointerException
04-23 16:02:02.252: ERROR/AndroidRuntime(1450):     at com.stellent.gorinka.MusicListActivity$2.handleMessage(MusicListActivity.java:81)
04-23 16:02:02.252: ERROR/AndroidRuntime(1450):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-23 16:02:02.252: ERROR/AndroidRuntime(1450):     at android.os.Looper.loop(Looper.java:123)
04-23 16:02:02.252: ERROR/AndroidRuntime(1450):     at android.app.ActivityThread.main(ActivityThread.java:4203)
04-23 16:02:02.252: ERROR/AndroidRuntime(1450):     at java.lang.reflect.Method.invokeNative(Native Method)
04-23 16:02:02.252: ERROR/AndroidRuntime(1450):     at java.lang.reflect.Method.invoke(Method.java:521)
04-23 16:02:02.252: ERROR/AndroidRuntime(1450):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
04-23 16:02:02.252: ERROR/AndroidRuntime(1450):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
04-23 16:02:02.252: ERROR/AndroidRuntime(1450):     at dalvik.system.NativeStart.main(Native Method)

I have declared the getter and setter methods in a seperate claa named SongsList. Plz help me determine the problem…

  • 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-05-14T14:33:22+00:00Added an answer on May 14, 2026 at 2:33 pm

    ProgressDialog p seems to be null when your Handler handler‘s handleMessage is called. I cannot see any code where you assign something to p, so I’m guessing the error is there…

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

Sidebar

Ask A Question

Stats

  • Questions 449k
  • Answers 449k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Handling concatenated bzip is fixed on trunk, or should be:… May 15, 2026 at 8:09 pm
  • Editorial Team
    Editorial Team added an answer This is described in the MT 'General Information' documentation. You… May 15, 2026 at 8:09 pm
  • Editorial Team
    Editorial Team added an answer Are you trying to get the position of mouse pointer… May 15, 2026 at 8:09 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.