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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:25:22+00:00 2026-05-27T04:25:22+00:00

What I try to do I got a ListView, with a OnItemClick in it,

  • 0

What I try to do


I got a ListView, with a OnItemClick in it, there I get the URL which I stored into, with this URL I set an Intent to an other Activity(WebView) to open up, the webpage.

Question


When I try to get the Intent, I allways get a Force-Close-Error but I don’t get why. It would be great if you find out whats wrong 🙁

The Code of both Activitys you find down here:

Code


test2.java -> Here I create the Intent

package de.stepforward;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;


import org.json.JSONArray;
import org.json.JSONObject;

import de.stepforward.web.ShowVideo;



import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;



public class test2 extends ListActivity {


    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


    String result = "";
    String line = null;
    final ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();


    //get the Data from URL
    try{
    URL url = new URL("http://gdata.youtube.com/feeds/mobile/users/TheStepForward/uploads?alt=json&format=1"); 

    URLConnection conn = url.openConnection();
    StringBuilder sb = new StringBuilder();
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));

    //read d response till d end
    while ((line = rd.readLine()) != null) {
    sb.append(line + "\n");
    }
    result = sb.toString();
    Log.v("log_tag", "Append String " + result);
    } catch (Exception e) {
    Log.e("log_tag", "Error converting result " + e.toString());
    }

    try{
        JSONObject json = new JSONObject(result);
        JSONObject feed = json.getJSONObject("feed");
        JSONArray entrylist = feed.getJSONArray("entry");

        for(int i=0;i<entrylist.length();i++){
            //Get Title
            JSONObject movie = entrylist.getJSONObject(i);
            JSONObject title = movie.getJSONObject("title");
            String txtTitle = title.getString("$t");
            Log.d("Title", txtTitle);

            //Get Description
            JSONObject content = movie.getJSONObject("content");
            String txtContent = content.getString("$t");
            Log.d("Content", txtContent);

            //Get Link
            JSONArray linklist = movie.getJSONArray("link");
            JSONObject link = linklist.getJSONObject(0);
            String txtLink = link.getString("href");
            Log.d("Link", txtLink);


            //Get Thumbnail
            JSONObject medialist = movie.getJSONObject("media$group");
            JSONArray thumblist = medialist.getJSONArray("media$thumbnail");
            JSONObject thumb = thumblist.getJSONObject(2);
            String txtThumb = thumb.getString("url");
            Log.d("Thumb", txtThumb.toString());


            //String Array daraus machen und in Hashmap füllen
            HashMap<String, String> map = new HashMap<String, String>();
            map.put("Thumb", txtThumb);
            map.put("Title", txtTitle);
            map.put("Content", txtContent);
            map.put("Link", txtLink);
            mylist.add(map);

        }
        //ListView füllen
        ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.lit, 
                new String[] { "Thumb","Title","Content","Link"}, 
                new int[] { R.id.img_video,R.id.txt_title,R.id.txt_subtitle});      
        setListAdapter(adapter);


        //OnClickLister um Youtube-Video zu öffnen
        final ListView lv = getListView();
            lv.setOnItemClickListener(new OnItemClickListener(){
                public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

                    //Video-Link auslesen
                    Map<String, String> map = mylist.get(position);
                    String link = map.get("Link");
                    Log.d("Link", link);

                    final Intent Showvideo = new Intent(test2.this, ShowVideo.class);
                    Showvideo.putExtra("VideoLink", link);

                    final Intent i = new Intent(test2.this, ShowVideo.class);
                    startActivity(i);

                }
            });



    }catch (Exception e) {
        Log.e("log_tag", "Error converting result " + e.toString());
        }
}
}

Showvideo.java -> Here I receive the Intent

package de.stepforward.web;

import de.stepforward.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class ShowVideo extends Activity {

    WebView mWebView;


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
            mWebView.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.showvideo);


    //Video-Link abfangen
    Bundle extras = getIntent().getExtras();
    String VideoLink = extras.getString("ShowVideo");


    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl(VideoLink);



    }




}

Thank you for the help in advance!

Best Regards

safari

Note: Sorry forget the Error-Log. Here you are:

Error-Log

11-29 08:57:57.258: W/dalvikvm(10944): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
11-29 08:57:57.258: E/AndroidRuntime(10944): FATAL EXCEPTION: main
11-29 08:57:57.258: E/AndroidRuntime(10944): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.stepforward/de.stepforward.web.ShowVideo}: java.lang.NullPointerException
11-29 08:57:57.258: E/AndroidRuntime(10944):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at android.app.ActivityThread.access$1500(ActivityThread.java:132)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at android.os.Looper.loop(Looper.java:143)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at android.app.ActivityThread.main(ActivityThread.java:4196)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at java.lang.reflect.Method.invokeNative(Native Method)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at java.lang.reflect.Method.invoke(Method.java:507)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at dalvik.system.NativeStart.main(Native Method)
11-29 08:57:57.258: E/AndroidRuntime(10944): Caused by: java.lang.NullPointerException
11-29 08:57:57.258: E/AndroidRuntime(10944):    at de.stepforward.web.ShowVideo.onCreate(ShowVideo.java:33)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
11-29 08:57:57.258: E/AndroidRuntime(10944):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
11-29 08:57:57.258: E/AndroidRuntime(10944):    ... 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-05-27T04:25:23+00:00Added an answer on May 27, 2026 at 4:25 am

    At first, please write variable names with a small letter and class names with a big letter at the beginning. And Camel-case in every name;

    So to your question I think the two answers should fix it. Just to have it in one place, your onItemClick method should look like this.

    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    
                    //Video-Link auslesen
                    Map<String, String> map = myList.get(position);
                    String link = map.get("Link");
                    Log.d("Link", link);
    
                    Intent i = new Intent(test2.this, ShowVideo.class);
                    i.putExtra("VideoLink", link);
                    startActivity(i);
    
                }
    

    Firstly you don’t have to create 2 intents. You just create one and give the context and the the class in the constructor and put the data in the same intent. The ShowVideo Activity doesn’t know anything about your second Intent. You save the extra with the key “VideoLink” and want to get the extra with the key “ShowVideo”. You have to use the same key otherwise you won’t get anything out of it. The error is because your extras are null and that could be because you don’t add any data to your real intent. You have to use one intent for the class and the data.

    the onCreate should look like:

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.showvideo);
    
    
    //Video-Link abfangen
    Bundle extras = getIntent().getExtras();
    String videoLink = extras.getString("VideoLink");
    
    ....
    
    }
    

    Secondly I would make a static constant in the ShowVideo Activity for your extra name.
    So at the top of the ShowVideo add

    public static final String EXTRA_VIDEO_LINK = "VideoLink";
    

    and instead of the “VideoLink” in your put and get extra you write ShowVideo.EXTRA_VIDEO_LINK
    That will prevent that you unintentionally have different keys.

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

Sidebar

Related Questions

I've got problem with Listview in Android. Then I try to set adapter to
What I try to do I got a ListView which I've filled over my
I got an array which I iterate over and try to create a variable.
I've got a file (test.txt) which contains 1234567. However when I try to read
I've got question about wpf xaml style definitions. When I try to set style
I've followed this tutorial but when I try to run the application I get
Hi ive got a custom listview and im trying to start a new activity
I got dtd in file and I cant remove it. When i try to
I got a little problem. Sometimes, when I try to call the following code,
When I try to start the Sql Server (SqlExpress) service I got the following

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.