0

Some time gets "Launch Cancelled" error. Gets stuck at 'Open Time Sheet ' Button btn01. Any help is appreciated.

TimeSheet.java

package com.example.TimeSheet;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class TimeSheet extends Activity 
{
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) 
 {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 startActivity(new Intent(this, MenuExample.class));
 }
} 

MenuExample.java

package com.example.TimeSheet;
import android.app.Activity;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.Button;
import android.widget.Toast;
public class MenuExample extends Activity
{ 
 @Override
 public void onCreate(Bundle savedInstanceState) 
 {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.menu); 
 Button btn = (Button) findViewById(R.id.btn1); 
 btn.setOnCreateContextMenuListener(this);
 }
 private void CreateMenu(Menu menu)
 {
 menu.setQwertyMode(true);
 MenuItem mnu1 = menu.add(0, 0, 0, "Fill Time Sheet");
 {
 mnu1.setAlphabeticShortcut('a');
 mnu1.setIcon(R.drawable.icon1);
 }
 MenuItem mnu2 = menu.add(0, 1, 1, "Check Time Sheet");
 {
 mnu2.setAlphabeticShortcut('b');
 mnu2.setIcon(R.drawable.icon2); 
 }
 MenuItem mnu3 = menu.add(0, 2, 2, "Exit Time Sheet");
 {
 mnu3.setAlphabeticShortcut('c');
 mnu3.setIcon(R.drawable.icon3);
 }
 }
 private boolean MenuChoice(MenuItem item)
 { 
 switch (item.getItemId()) 
 {
 case 0:
 Toast.makeText(this, "You clicked on Item 1", 
 Toast.LENGTH_LONG).show();
 return true;
 case 1:
 Toast.makeText(this, "You clicked on Item 2", 
 Toast.LENGTH_LONG).show();
 return true;
 case 2:
 Toast.makeText(this, "You clicked on Item 3", 
 Toast.LENGTH_LONG).show();
 return true;
 }
 return false;
 } 
 // Using Context Menu
 /*
 @Override
 public boolean onCreateOptionsMenu(Menu menu)
 {
 super.onCreateOptionsMenu(menu);
 CreateMenu(menu);
 return true;
 }*/
 @Override
 public boolean onOptionsItemSelected(MenuItem item)
 { 
 return MenuChoice(item); 
 }
 @Override
 public void onCreateContextMenu(ContextMenu menu, View view, 
 ContextMenuInfo menuInfo) 
 {
 super.onCreateContextMenu(menu, view, menuInfo);
 CreateMenu(menu);
 }
 @Override
 public boolean onContextItemSelected(MenuItem item)
 { 
 return MenuChoice(item); 
 } 
}

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">
</LinearLayout>

menu.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">
 <Button android:id="@+id/btn1"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content" 
 android:text = "Open Time Sheet"/> 
</LinearLayout> 

..................................
[2010年09月27日 00:51:57 - TimeSheet] HOME is up on device 'emulator-5554'
[2010年09月27日 00:51:57 - TimeSheet] Uploading TimeSheet.apk onto device 'emulator-5554'
[2010年09月27日 00:52:08 - TimeSheet] Failed to upload TimeSheet.apk on device 'emulator-5554'
[2010年09月27日 00:52:08 - TimeSheet] java.io.IOException: Unable to upload file: null
[2010年09月27日 00:52:08 - TimeSheet] Launch canceled!

asked Sep 26, 2010 at 16:08
5
  • sorry for the inconvenience because of false editing. Commented Sep 26, 2010 at 16:10
  • <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:id="@+id/btn1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text = "Open Time Sheet"/> </LinearLayout> Commented Sep 26, 2010 at 16:13
  • Can you describe in more detail the exact error you are getting, including stack trace? use adb logcat to get the stack trace. Commented Sep 26, 2010 at 16:47
  • i cnt put d whole stack trace here.... Commented Sep 26, 2010 at 17:12
  • I have edited question with stack trace.Please help me out. I have gone through other questions from site to get help, but unfortunately, solutions mentioned there are not useful for me. Commented Sep 27, 2010 at 0:06

1 Answer 1

3

In Eclipse, go to Window -> Preferences -> Android -> DDMS -> ADB connection timeout...

Set to something bigger, like 10000 (ms).

I was having the same problem and this solved it.

answered Oct 9, 2010 at 16:20
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.