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

  • Home
  • SEARCH
  • 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 4559206
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:45:21+00:00 2026-05-21T17:45:21+00:00

hi i am passing array of strings from activity A to Activity B. in

  • 0

hi i am passing array of strings from activity A to Activity B. in activity B i am able to get this Array of strings within OnCreate() method .but if i use this array in a Separate class which is outside onCreate() method but in same activity B then this array showing null values. I am declaring the array as a global.

please tell me how to access this array into a seperate class outside the onCreate() method but within same activity…

this is activity A

public class mymap extends Activity {
/** Called when the activity is first created. */

public  static  String arr[]={"40.748963847316034","-73.96807193756104" ,"United Nations",
    "40.76866299974387","-73.98268461227417","Lincoln Center",
    "40.765136435316755","-73.97989511489868","Carnegie Hall",
    "40.70686417491799","-74.01572942733765","The Downtown Club",
    "1.352566007"," 103.78921587","Singapore",
    "12.971598","77.594562","Bangalore"};
public  static  String animatel[]={"12.971598","77.594562"};

public static int[] Icons = {
R.drawable.drinkingfountain,
R.drawable.pin,
R.drawable.helicopter,
R.drawable.levelcrossing,
R.drawable.ter,
R.drawable.templehindu

};

public static int[] Icons1 = {
R.drawable.icon,
R.drawable.pin,
R.drawable.f_icon,
R.drawable.icon,
R.drawable.pin,
R.drawable.f_icon

};

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Intent intent = new Intent(mymap.this,test.class);
    intent.putExtra("ll",arr );
    intent.putExtra("markers",Icons );
    intent.putExtra("images",Icons1 );
    intent.putExtra("anill", animatel);
    startActivity(intent);
}

}

this is Activity B

public class mapll extends MapActivity {
private MapView map=null;
private MyLocationOverlay me=null;
public static GeoPoint p;
public static String[] arr;
public static ArrayList Icons;
public static ArrayList Icons1;
public static Drawable marker1;

public static ArrayList arrtp = new ArrayList();
public static ArrayList Iconstp = new ArrayList();
public static ArrayList Icons1tp = new ArrayList();
public static ArrayList tp = new ArrayList();

String[] animatel;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d(“prabhu”,”Inside the ocreate mapll”);
arr = getIntent().getStringArrayExtra(“ll”);
// for(int i=0;i
map=(MapView)findViewById(R.id.map);

//map.getController().setCenter(getPoint("40.76793169992044","-73.98180484771729"));
map.getController().setZoom(5);
map.setBuiltInZoomControls(true);


Drawable marker=getResources().getDrawable(R.drawable.pin);

marker.setBounds(0, 0, marker.getIntrinsicWidth(),
marker.getIntrinsicHeight());

me=new MyLocationOverlay(this, map);
map.getOverlays().add(me);
map.getOverlays().add(new SitesOverlay(marker));
map.setSatellite(true);

map.getController().animateTo(getPoint(mymap.animatel[0],mymap.animatel[1]));


}

@Override
public void onResume() {
super.onResume();

me.enableCompass();
}

@Override
public void onPause() {
super.onPause();

me.disableCompass();
}

  @Override
protected boolean isRouteDisplayed() {
return(false);
}

  @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_S) {
map.setSatellite(!map.isSatellite());
return(true);
}
else if (keyCode == KeyEvent.KEYCODE_Z) {
map.displayZoomControls(true);
return(true);
}

return(super.onKeyDown(keyCode, event));
}

private GeoPoint getPoint(String arr, String arr2) {
    double lat = Double.parseDouble(arr);
    double lon = Double.parseDouble(arr2);
return(new GeoPoint((int)(lat*1E6),
(int)(lon*1E6)));
}

class SitesOverlay extends ItemizedOverlay<OverlayItem> {

    private List<OverlayItem> items=new ArrayList<OverlayItem>();
    //private Drawable pin=null;
    OverlayItem pi=null;
    public SitesOverlay(Drawable marker) {
    super(marker);
    Log.d("prabhu","Inside the ");
    //this.pin=marker;

// Icons1= getIntent().getExtras().getIntArray(“images”);
// Icons= getIntent().getExtras().getIntArray(“markers”);
// arr = getIntent().getExtras().getStringArray(“ll”);
boundCenterBottom(marker);

    Log.d("prabhu","arr len  "+arr.length);
    for(int i=0;i<mapll.arr.length;i=i+3)
    {

        String add = "";
         Geocoder geoCoder = new Geocoder(

                 getApplicationContext(), Locale.getDefault());
             try {
                //Log.d("prabhu","in try");
                mapll.p= getPoint(mymap.arr[i],mymap.arr[i+1]);
                 List<Address> addresses = geoCoder.getFromLocation(
                        mapll.p.getLatitudeE6()  / 1E6, 
                       mapll.  p.getLongitudeE6() / 1E6, 1);

                 if (addresses.size() > 0) 
                 {

                    Log.d("prabhu","in try");
                     for (int k=0; k<addresses.get(0).getMaxAddressLineIndex(); 
                          k++)

                      add += addresses.get(0).getAddressLine(k) + "\n";
                 Log.d("prabhu","address"+add);
                 }

                 //Toast.makeText(getBaseContext(), add, Toast.LENGTH_SHORT).show();
             }
             catch (IOException e) {  
                   Log.d("prabhu","exception occured");
                 e.printStackTrace();
             }   

// map.getController().animateTo(p);
items.add(new OverlayItem(getPoint(mymap.arr[i],mymap.arr[i+1]),””,add));

             add = "";
    }

    for(int m=0;m<mymap.Icons.length;m++){
        mapll. marker1=getResources().getDrawable(mymap.Icons[m]);

        mapll.marker1.setBounds(0, 0,mapll. marker1.getIntrinsicWidth(),
        mapll.marker1.getIntrinsicHeight());
        items.get(m).setMarker(mapll.marker1);
        boundCenterBottom(mapll.marker1);
    Log.d("prabhu","items      "+items.get(m));

    }

    }




    @Override
    protected OverlayItem createItem(int j) {
    return(items.get(j));
    }

    @Override
    protected boolean onTap(int j) {
    //Toast.makeText(NooYawk.this,items.get(j).getSnippet(),Toast.LENGTH_SHORT).show();
        Context mContext = getApplicationContext();
        Dialog dialog = new Dialog(mapll.this);

        dialog.setContentView(R.layout.dialog);
        //dialog.setTitle("Custom Dialog");

        TextView text = (TextView) dialog.findViewById(R.id.text);
        text.setText(items.get(j).getSnippet());

        ImageView image = (ImageView) dialog.findViewById(R.id.image);

        image.setBackgroundResource(mymap.Icons1[j]);
        dialog.show();
        dialog.setCanceledOnTouchOutside(true);

        return true;


    }

    @Override
    public int size() {
    return(items.size());
    }
    private GeoPoint getPoint(String arr, String arr2) {
        double lat = Double.parseDouble(arr);
        double lon = Double.parseDouble(arr2);
    return(new GeoPoint((int)(lat*1E6),
    (int)(lon*1E6)));
    }
}



}

i am getting this error : FATAL EXCEPTION: main

ERROR/AndroidRuntime(15822): java.lang.NoClassDefFoundError:

ERROR/dalvikvm(15822): Could not find class ‘com.prabhu.android.mapll’, referenced from method com.prabhu.android.mymap.onCreate
ERROR/AndroidRuntime(15822): FATAL EXCEPTION: main
ERROR/AndroidRuntime(15822): java.lang.NoClassDefFoundError: com.prabhu.android.mapll
ERROR/AndroidRuntime(15822): at com.prabhu.android.mymap.onCreate(mymap.java:49)
ERROR/AndroidRuntime(15822): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
ERROR/AndroidRuntime(15822): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2633)
ERROR/AndroidRuntime(15822): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2685)
04-28 10:28:26.337: ERROR/AndroidRuntime(15822): at android.app.ActivityThread.access$2300(ActivityThread.java:126)
04-28 10:28:26.337: ERROR/AndroidRuntime(15822): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2038)
04-28 10:28:26.337: ERROR/AndroidRuntime(15822): at android.os.Handler.dispatchMessage(Handler.java:99)
04-28 10:28:26.337: ERROR/AndroidRuntime(15822): at android.os.Looper.loop(Looper.java:123)
04-28 10:28:26.337: ERROR/AndroidRuntime(15822): at android.app.ActivityThread.main(ActivityThread.java:4633)
04-28 10:28:26.337: ERROR/AndroidRuntime(15822): at java.lang.reflect.Method.invokeNative(Native Method)
04-28 10:28:26.337: ERROR/AndroidRuntime(15822): at java.lang.reflect.Method.invoke(Method.java:521)
04-28 10:28:26.337: ERROR/AndroidRuntime(15822): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
04-28 10:28:26.337: ERROR/AndroidRuntime(15822): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-28 10:28:26.337: ERROR/AndroidRuntime(15822): at dalvik.system.NativeStart.main(Native Method)

  • 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-21T17:45:22+00:00Added an answer on May 21, 2026 at 5:45 pm

    Make a String array (say strArray variable) in your Activity B and while coming from first Activity A, in onCreate() of Activity B method

    strArray = getIntent().getStringArrayExtra("GiveMeArray");
    

    now you can use your array in separate class but within same Activity

    Edit:

    In your Class mymap while defining the Intent

    Intent intent = new Intent(mymap.this,test.class); //  <<< what is test.class
    intent.putExtra("ll",arr );
    

    What is test.class, and your Activity B is mapll

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

Sidebar

Related Questions

I'm passing a reference of a form to a class. Within this class I
i am struck with passing String array from one activity to another using intent.
If I am passing an object to a method, why should I use the
I am having trouble passing data from one activity to another. I can easily
Looking to pass variables from c# to javascript to use some jquery code. Passing
I've read several discussions of passing char * in C. stackoverflow: passing-an-array-of-strings-as-parameter-to-a-function-in-c stackoverflow: how-does-an-array-of-pointers-to-pointers-work
I got this error when using the Twitter gem, and passing in an array.
i want to call activity B from Activity A. I want to write method
I'm passing an array from my Rails app to Javascript via a js.erb template.
Passing an undimensioned array to the VB6's Ubound function will cause an error, so

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.