0
votes
public class BekaaActivity extends Activity implements AdapterView.OnItemSelectedListener{
Spinner bekaa=null;
Intent intent;
String[] info;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bekaaarea);
    bekaa=(Spinner)findViewById(R.id.spinner1);
    bekaa.setOnItemSelectedListener(this);

}

public void onNothingSelected(AdapterViewparent){}

public void onItemSelected(AdapterView<?>parent,View view,int pos,long id){




    if(((TextView)view).getText().equals("Sohmor")){

         String[] info = {"Adel","70858243","8-10-12","70$","sohmor"};





                Intent i = new Intent("net.learn2develop.AutocarActivity");
                Bundle extras = new Bundle();
                extras.putStringArray("strings",info);

                i.putExtras(extras);
                startActivityForResult(i, 1);



    }



//tv1.setText(((TextView)view).getText());

}

Whenever i click Sohmor item, the application crashes, i don't know why . i followed the error and i find it when i want to start new Activity here's the log 04-05 22:55:02.157: D/dalvikvm(12477): GC_FOR_ALLOC freed 61K, 27% free 2752K/3728K, paused 0ms, total 0ms 04-05 22:55:02.157: I/dalvikvm-heap(12477): Grow heap (frag case) to 2.999MB for 294384-byte allocation 04-05 22:55:02.187: D/dalvikvm(12477): GC_FOR_ALLOC freed <1K, 25% free 3039K/4016K, paused 30ms, total 30ms 04-05 22:55:02.477: I/PGA(12477): Attempting to create new SOCKET connectionn pid = 12477, tid = 12477 04-05 22:55:02.487: I/PGA(12477): New SOCKET connection: com.example.liutransportations (pid 12477, tid 12477) 04-05 22:55:11.077: W/InputEventReceiver(12477): Attempted to finish an input event but the input event receiver has already been disposed. 04-05 22:55:11.227: W/Instrumentation(12477): Unresolved intent: cmp: null 04-05 22:55:11.227: W/Instrumentation(12477): Unresolved intent: data: 04-05 22:55:11.227: D/AndroidRuntime(12477): Shutting down VM 04-05 22:55:11.227: W/dalvikvm(12477): threadid=1: thread exiting with uncaught exception (group=0x95d28b20) 04-05 22:55:11.227: I/Process(12477): Sending signal. PID: 12477 SIG: 9

1

1 Answers

0
votes

What is this?

Intent i = new Intent("net.learn2develop.AutocarActivity");

if you have an activity with name "AutocarActivity" and you want to open it try this code

Intent i = new Intent(this, AutocarActivity.class);
                Bundle extras = new Bundle();
                extras.putStringArray("strings",info);

                i.putExtras(extras);
                startActivityForResult(i, 1);

Not: You must to declare the activity in your manifest file So you must to replace

Intent i = new Intent("net.learn2develop.AutocarActivity");

With :

Intent i = new Intent(this, AutocarActivity.class);

For more info about intents Intent class