Hi Everyone
When i Pressed Send My Location from Menu in my application .Runtime
terminates my application by giving me an error.
error :The application Final Year Project (Process
com.android.myproject) has Stopped Unexpectedly.please try again.
After that my appication is forcefully Terminated.
my Code is
package com.android.myproject;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
public class myActivity extends Activity {
/** Called when the activity is first created. */
private static final int MENU1 = Menu.FIRST;
private static final int MENU2 = Menu.FIRST + 1;
private static final int MENU3 = Menu.FIRST + 2;
private static final int MENU4 = Menu.FIRST + 3;
private static final int MENU5 = Menu.FIRST + 4;
private static final int MENU6 = Menu.FIRST + 5;
private static final int MENU7 = Menu.FIRST + 6;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Toast.makeText(myActivity.this,"MY First Toast",
Toast.LENGTH_LONG).show();
}
public boolean onCreateOptionsMenu(Menu menu){
menu.add(0, MENU1, 0, "My location");
menu.add(0, MENU2, 0, "Send My Location");
menu.add(0, MENU3, 0, "Request Locaiton");
menu.add(0, MENU4, 0, "View Map");
menu.add(0, MENU5, 0, "Distance");
menu.add(0, MENU6, 0, "Remain Time");
menu.add(0, MENU7, 0, "Qiut");
return true;
}
public boolean onOptionsItemSelected(MenuItem menuitem){
switch(menuitem.getItemId()){
case MENU1:
//When My Location is Selected
launchMyLocationActivity();
return true;
case MENU2:
//When Send My Location is Selected
launchSendMyLocation();
return true;
case MENU3:
//When Request Location is Selected
launchRequestLocation();
return true;
case MENU4:
//When View Map is Selected
showMapView();
return true;
case MENU5:
//When Distance is Selected
RemainDistance();
return true;
case MENU6:
//When Time is Selected
DisplayRemainingTime();
return true;
case MENU7:
finish();
return true;
}
return false;
}
public void launchMyLocationActivity(){
Intent myLocationActivityLauncher = new
Intent(this,MyLocationActivity.class);
startActivity(myLocationActivityLauncher);
}
public void launchRequestLocation(){
Intent requestlocationLauncher = new Intent(this,
RequestLocation.class);
startActivity(requestlocationLauncher);
}
public void launchSendMyLocation(){
Intent launchSendMyLocationActivity = new Intent(this,
SendMyLocation.class);
startActivity(launchSendMyLocationActivity);
}
public void DisplayRemainingTime(){
Toast.makeText(this, "Remain Time to Distinaiton",
Toast.LENGTH_LONG).show();
}
public void RemainDistance(){
Toast.makeText(this, "Remaining Distance is =",
Toast.LENGTH_LONG).show();
}
public void showMapView(){
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en