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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:30:31+00:00 2026-06-02T07:30:31+00:00

I am trying to do an intent from ShoutActivity that extends activity to MyListActivity

  • 0

I am trying to do an intent from ShoutActivity that extends activity to MyListActivity that extends ListActivity on a Click

the App reaches when its reaches the intent

code:

first activity:

public class ShoutActivity extends Activity implements View.OnClickListener{
    /** Called when the activity is first created. */


private Button b1;
private Button b2;
private EditText text_box;



@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    b1 = (Button) this.findViewById(R.id.button1);
    b1.setOnClickListener(this);

    b2 = (Button) this.findViewById(R.id.button04);
    b2.setOnClickListener(this);
            //.....other stuff

}

public void onClick(View v) {
    if (v==b1)
    {   
        //not important
    }
        if(v==b2){

                Intent intent = new Intent();               

intent.setClass(ShoutActivity.this,MyListActivity.class);
);
                        Bundle myBundle = new Bundle();
                        myBundle.putStringArray("List", s1);
                        intent.putExtras(myBundle);
                        startActivity(intent);

        }
    }

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="1">

    <EditText android:layout_width="match_parent" android:id="@+id/editText1" android:layout_height="wrap_content">
        <requestFocus></requestFocus>
    </EditText>
    <Button android:text="Shout !" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
    <Button android:text="View Shouts" android:id="@+id/button04" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

</LinearLayout>

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="karim.mobi"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".ShoutActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".MyListActivity" android:label="@string/app_name"
          android:theme="@android:style/Theme.NoTitleBar"/>

    </application>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
</manifest>

second activity

package karim.mobi;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.view.View;
import android.widget.*;
import android.app.*;

public class MyListActivity extends ListActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);
        String s[];
        s= savedInstanceState.getStringArray("List");
        setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,s));
        getListView().setTextFilterEnabled(true);
    }

}

error logcat:

04-21 21:29:31.177: ERROR/AndroidRuntime(789): FATAL EXCEPTION: main
04-21 21:29:31.177: ERROR/AndroidRuntime(789): java.lang.RuntimeException: Unable to start activity ComponentInfo{karim.mobi/karim.mobi.MyListActivity}: java.lang.NullPointerException
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at android.os.Looper.loop(Looper.java:123)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at java.lang.reflect.Method.invokeNative(Native Method)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at java.lang.reflect.Method.invoke(Method.java:521)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at dalvik.system.NativeStart.main(Native Method)
04-21 21:29:31.177: ERROR/AndroidRuntime(789): Caused by: java.lang.NullPointerException
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at karim.mobi.MyListActivity.onCreate(MyListActivity.java:21)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-21 21:29:31.177: ERROR/AndroidRuntime(789):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

can you please tell me whats the problem ?

please be specific

  • 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-02T07:30:33+00:00Added an answer on June 2, 2026 at 7:30 am

    First, you must need to set content-view for your MyListActivity. So you need to call the following right after super.onCreate:

    setContentView(R.layout.your_layout_name);
    

    Second, you are reading the array wrong in that same activity.

    Change this:

    s= savedInstanceState.getStringArray("List");
    

    To this:

    s= getIntent().getExtras().getStringArray("List");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to start an activity from my main activity. Its not working
I'm trying to pass data from one activity to another via Intent.putExtras like this:
I'm trying to start a service from my activity like this: startService(new Intent(MyActivity.this, MyService.class));
I'm trying to launch an intent from my application that will play audio from
I am trying to launch a MapActivity from Activity using intent. Following is how
I am trying to send an email from my app. the code goes lik
I am trying to send data from an activity to service via intents. This
I'm trying to use a standard Intent that will take a picture, then allow
I am trying to get a list of receivers that handle android.intent.action.BOOT_COMPLETED for other
Im trying to display the image i have coming from an intent.putExtra on a

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.