Re: [android-developers] Re: help: dont display Toast

2011-04-10 Thread luiX_
I didn't too. Any particular reason to use Asyntasks instead of threads? I
don't if it has any benefit.
El 09/04/2011 20:53, ABSOLUT davidt...@gmail.com escribió:
 Yes, everything is ok.

 Anyway, I didnt know that I cant use long operations inside oncreate
 method. I'm trying to use asyntask or thread to do these things.

 Thanks


 On 9 abr, 20:38, Kostya Vasilyev kmans...@gmail.com wrote:
 And does that work? :)
 09.04.2011 22:35 пользователь ABSOLUT davidt...@gmail.com написал:

  Many thanks,
  I'm using now Asyntask and I'm using Toast in PreExecute and
  PostExecute methods.

  On 9 abr, 18:51, Kostya Vasilyev kmans...@gmail.com wrote:
  Your code, as far as I can tell, runs inside onCreate. Android UI
 framework
  is designed so that it expects callbacks like onCreate and others to
 return
  control to Android within a reasonable amount of time.

  Your code prevents Android from doing things in the UI, including
showing
  toasts (or dialogs), because it ties up the UI thread with your work
  function.

  Study Application fundamentals in the SDK documentation, specifically
  information about threads, it does a good job at explaining this.

  To run networking code, create a background thread. An easy way to do
it
 is
  to use AsyncTask, a generic class provided by the Android framework.
  09.04.2011 20:06 пользователь ABSOLUT davidt...@gmail.com написал:

   I dont understand what do you say Kostya
   I've installed the app in the devices but the Toast doesnt shows.
   The complete Oncreate is:

   public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   Log.d(PRUEBA, COMENZAMOS EL PROGRAMA);

   // Toast.makeText(ssh.this, ,
   Toast.LENGTH_SHORT).show();

   InetAddress pp;
   InetAddress direccionMaquinon;

   if (pruebaPing(221.221.221.2)){
   Log.d(PRUEBA,No llega despues de comprobar el primer ping.
   Hay que mandar paquete);
   Toast.makeText(this, ,
   Toast.LENGTH_SHORT).show();

   wakeonLan();
   Toast.makeText(this, ,
   Toast.LENGTH_SHORT).show();
   mandarSsh();
   }else{
   Log.d(PRUEBA,slllega);
   mandarSsh();
   }
   }
   public void wakeonLan (){

   try {
   Toast.makeText(this, Nsdfsdfdsfd paquete magico en...,
   Toast.LENGTH_LONG).show();

   final int PORT = 9;
   String ipStr = 221.x
   ...
   ...

   On 9 abr, 17:24, Kostya Vasilyev kmans...@gmail.com wrote:
   The toast will only show after your code returns from onCreate,
which
 it
   should.
   09.04.2011 19:01 пользователь ABSOLUT davidt...@gmail.com
написал:

Hi again,
I can't understand nothing.
I'm trying to execute a simple toast when the activity create but
doenn't show anything:

code:

public class ssh extends Activity {
/** Called when the activity is first created. */
public static final int PORT = 9;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d(PRUEBA, COMENZAMOS EL PROGRAMA);

Toast.makeText(ssh.this, ,
Toast.LENGTH_SHORT).show();
...


On 9 abr, 12:26, Kostya Vasilyev kmans...@gmail.com wrote:
OK. Try calling Toast from the UI thread. You can use Handler
for
  this.
09.04.2011 14:10 пользователь ABSOLUT davidt...@gmail.com
 написал:

 Yes I'm sure.

 I have:

 public void wakeonLan (){
 ..
 
 while (pruebaPing(maquina)){
 //MIENTR=AS NO RESPONDA A PING. DORMIMOS 6 SEGUNDOS EL
 PROCESO

 Thread.sleep(6000);
 contadorDormido=contadorDormido+6;
 Log.d(PRUEBA, No responde a ping despues de mandar el
 paquete magico en... + contadorDormido);
 Toast.makeText(getApplicationContext(), No responde a
 ping despues de mandar el paquete magico en... +
 contadorDormido,
 Toast.LENGTH_SHORT).show();
 Toast.makeText(this, No esponde a ping despues de
 mandar el paquete magico en... + contadorDormido,
 Toast.LENGTH_SHORT).show();
 Toast.makeText(ssh.this.getApplicationContext(), No
 responde a ping despues de mandar el paquete magico en... +
 contadorDormido, Toast.LENGTH_SHORT).show();
 

 And I can see the logcat

 Please any help?
 Many thanks

 On 9 abr, 11:49, Kostya Vasilyev kmans...@gmail.com wrote:
 Are you sure this code actually runs, and calls Toast? Add
 logcat
printouts
 just before Toast to make sure.
 09.04.2011 13:13 пользователь David Tabernero 

  davidt...@gmail.com

 написал:

  Hi,

  I can't display Toast in my application:

  I have this code but nothing happens. Any help please?

  Many thanks and sorry for my english!

  
  
  public void wakeonLan 

Re: [android-developers] Re: help: dont display Toast

2011-04-10 Thread TreKing
On Sun, Apr 10, 2011 at 10:55 AM, luiX_ lui...@gmail.com wrote:

 Any particular reason to use Asyntasks instead of threads?


It simplifies running a background operation while interacting with the main
thread (to show progress or do something on the main thread when the long
running operation completes).

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: help: dont display Toast

2011-04-09 Thread Kostya Vasilyev
OK. Try calling Toast from the UI thread. You can use Handler for this.
09.04.2011 14:10 пользователь ABSOLUT davidt...@gmail.com написал:
 Yes I'm sure.

 I have:


 public void wakeonLan (){
 ..
 
 while (pruebaPing(maquina)){
 //MIENTR=AS NO RESPONDA A PING. DORMIMOS 6 SEGUNDOS EL
 PROCESO

 Thread.sleep(6000);
 contadorDormido=contadorDormido+6;
 Log.d(PRUEBA, No responde a ping despues de mandar el
 paquete magico en... + contadorDormido);
 Toast.makeText(getApplicationContext(), No responde a
 ping despues de mandar el paquete magico en... + contadorDormido,
 Toast.LENGTH_SHORT).show();
 Toast.makeText(this, No esponde a ping despues de
 mandar el paquete magico en... + contadorDormido,
 Toast.LENGTH_SHORT).show();
 Toast.makeText(ssh.this.getApplicationContext(), No
 responde a ping despues de mandar el paquete magico en... +
 contadorDormido, Toast.LENGTH_SHORT).show();
 


 And I can see the logcat

 Please any help?
 Many thanks


 On 9 abr, 11:49, Kostya Vasilyev kmans...@gmail.com wrote:
 Are you sure this code actually runs, and calls Toast? Add logcat
printouts
 just before Toast to make sure.
 09.04.2011 13:13 пользователь David Tabernero davidt...@gmail.com
 написал:

  Hi,

  I can't display Toast in my application:

  I have this code but nothing happens. Any help please?

  Many thanks and sorry for my english!

  
  
  public void wakeonLan (){

  try {
  while (pruebaPing(maquina)){
  Toast.makeText(ssh.this, No responde a ping despues de
  mandar el paquete magico en... + contadorDormido,
  Toast.LENGTH_SHORT).show();
  Toast.makeText(getApplicationContext(), No responde a ping
  despues de mandar el paquete magico en... + contadorDormido,
  Toast.LENGTH_SHORT).show();
  
  .

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to
android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: help: dont display Toast

2011-04-09 Thread luiX_
Hmm... that should work fine.

Are you running that in a real device? I've had problems not seeing Toasts
in the emulator...

2011/4/9 ABSOLUT davidt...@gmail.com

 Hi again,
 I can't understand nothing.
 I'm trying to execute a simple toast when the activity create but
 doenn't show anything:

 code:

 public class ssh extends Activity {
/** Called when the activity is first created. */
public static final int PORT = 9;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d(PRUEBA, COMENZAMOS EL PROGRAMA);

Toast.makeText(ssh.this, ,
 Toast.LENGTH_SHORT).show();
...
 







 On 9 abr, 12:26, Kostya Vasilyev kmans...@gmail.com wrote:
  OK. Try calling Toast from the UI thread. You can use Handler for this.
  09.04.2011 14:10 пользователь ABSOLUT davidt...@gmail.com написал:
 
   Yes I'm sure.
 
   I have:
 
   public void wakeonLan (){
   ..
   
   while (pruebaPing(maquina)){
   //MIENTR=AS NO RESPONDA A PING. DORMIMOS 6 SEGUNDOS EL
   PROCESO
 
   Thread.sleep(6000);
   contadorDormido=contadorDormido+6;
   Log.d(PRUEBA, No responde a ping despues de mandar el
   paquete magico en... + contadorDormido);
   Toast.makeText(getApplicationContext(), No responde a
   ping despues de mandar el paquete magico en... + contadorDormido,
   Toast.LENGTH_SHORT).show();
   Toast.makeText(this, No esponde a ping despues de
   mandar el paquete magico en... + contadorDormido,
   Toast.LENGTH_SHORT).show();
   Toast.makeText(ssh.this.getApplicationContext(), No
   responde a ping despues de mandar el paquete magico en... +
   contadorDormido, Toast.LENGTH_SHORT).show();
   
 
   And I can see the logcat
 
   Please any help?
   Many thanks
 
   On 9 abr, 11:49, Kostya Vasilyev kmans...@gmail.com wrote:
   Are you sure this code actually runs, and calls Toast? Add logcat
  printouts
   just before Toast to make sure.
   09.04.2011 13:13 пользователь David Tabernero davidt...@gmail.com
   написал:
 
Hi,
 
I can't display Toast in my application:
 
I have this code but nothing happens. Any help please?
 
Many thanks and sorry for my english!
 


public void wakeonLan (){
 
try {
while (pruebaPing(maquina)){
Toast.makeText(ssh.this, No responde a ping despues de
mandar el paquete magico en... + contadorDormido,
Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), No responde a ping
despues de mandar el paquete magico en... + contadorDormido,
Toast.LENGTH_SHORT).show();

.
 
--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to
 
  android-developers@googlegroups.com
 
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
   http://groups.google.com/group/android-developers?hl=en
 
   --
   You received this message because you are subscribed to the Google
   Groups Android Developers group.
   To post to this group, send email to
 android-developers@googlegroups.com
   To unsubscribe from this group, send email to
   android-developers+unsubscr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: help: dont display Toast

2011-04-09 Thread Kostya Vasilyev
The toast will only show after your code returns from onCreate, which it
should.
09.04.2011 19:01 пользователь ABSOLUT davidt...@gmail.com написал:
 Hi again,
 I can't understand nothing.
 I'm trying to execute a simple toast when the activity create but
 doenn't show anything:

 code:

 public class ssh extends Activity {
 /** Called when the activity is first created. */
 public static final int PORT = 9;

 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 Log.d(PRUEBA, COMENZAMOS EL PROGRAMA);

 Toast.makeText(ssh.this, ,
 Toast.LENGTH_SHORT).show();
 ...
 







 On 9 abr, 12:26, Kostya Vasilyev kmans...@gmail.com wrote:
 OK. Try calling Toast from the UI thread. You can use Handler for this.
 09.04.2011 14:10 пользователь ABSOLUT davidt...@gmail.com написал:

  Yes I'm sure.

  I have:

  public void wakeonLan (){
  ..
  
  while (pruebaPing(maquina)){
  //MIENTR=AS NO RESPONDA A PING. DORMIMOS 6 SEGUNDOS EL
  PROCESO

  Thread.sleep(6000);
  contadorDormido=contadorDormido+6;
  Log.d(PRUEBA, No responde a ping despues de mandar el
  paquete magico en... + contadorDormido);
  Toast.makeText(getApplicationContext(), No responde a
  ping despues de mandar el paquete magico en... + contadorDormido,
  Toast.LENGTH_SHORT).show();
  Toast.makeText(this, No esponde a ping despues de
  mandar el paquete magico en... + contadorDormido,
  Toast.LENGTH_SHORT).show();
  Toast.makeText(ssh.this.getApplicationContext(), No
  responde a ping despues de mandar el paquete magico en... +
  contadorDormido, Toast.LENGTH_SHORT).show();
  

  And I can see the logcat

  Please any help?
  Many thanks

  On 9 abr, 11:49, Kostya Vasilyev kmans...@gmail.com wrote:
  Are you sure this code actually runs, and calls Toast? Add logcat
 printouts
  just before Toast to make sure.
  09.04.2011 13:13 пользователь David Tabernero davidt...@gmail.com
  написал:

   Hi,

   I can't display Toast in my application:

   I have this code but nothing happens. Any help please?

   Many thanks and sorry for my english!

   
   
   public void wakeonLan (){

   try {
   while (pruebaPing(maquina)){
   Toast.makeText(ssh.this, No responde a ping despues de
   mandar el paquete magico en... + contadorDormido,
   Toast.LENGTH_SHORT).show();
   Toast.makeText(getApplicationContext(), No responde a ping
   despues de mandar el paquete magico en... + contadorDormido,
   Toast.LENGTH_SHORT).show();
   
   .

   --
   You received this message because you are subscribed to the Google
   Groups Android Developers group.
   To post to this group, send email to

 android-developers@googlegroups.com

   To unsubscribe from this group, send email to
   android-developers+unsubscr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to
android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: help: dont display Toast

2011-04-09 Thread luiX_
You have your Toast message inside an if, are you sure that condition is
satisfied? Also, if you uncomment the first toast, does it show?

2011/4/9 ABSOLUT davidt...@gmail.com

 I dont understand what do you say Kostya
 I've installed the app in the devices but the Toast doesnt shows.
 The complete Oncreate is:

  public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d(PRUEBA, COMENZAMOS EL PROGRAMA);

   // Toast.makeText(ssh.this, ,
 Toast.LENGTH_SHORT).show();

 InetAddress pp;
InetAddress direccionMaquinon;

if (pruebaPing(221.221.221.2)){
Log.d(PRUEBA,No llega despues de comprobar el primer
 ping.
 Hay que mandar paquete);
Toast.makeText(this, ,
 Toast.LENGTH_SHORT).show();

wakeonLan();
Toast.makeText(this, ,
 Toast.LENGTH_SHORT).show();
mandarSsh();
}else{
Log.d(PRUEBA,slllega);
mandarSsh();
}
 }
 public void wakeonLan (){


try {
Toast.makeText(this, Nsdfsdfdsfd paquete magico en...,
 Toast.LENGTH_LONG).show();


final int PORT = 9;
String ipStr = 221.x
 ...
 ...



 On 9 abr, 17:24, Kostya Vasilyev kmans...@gmail.com wrote:
  The toast will only show after your code returns from onCreate, which it
  should.
  09.04.2011 19:01 пользователь ABSOLUT davidt...@gmail.com написал:
 
   Hi again,
   I can't understand nothing.
   I'm trying to execute a simple toast when the activity create but
   doenn't show anything:
 
   code:
 
   public class ssh extends Activity {
   /** Called when the activity is first created. */
   public static final int PORT = 9;
 
   @Override
   public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   Log.d(PRUEBA, COMENZAMOS EL PROGRAMA);
 
   Toast.makeText(ssh.this, ,
   Toast.LENGTH_SHORT).show();
   ...
   
 
   On 9 abr, 12:26, Kostya Vasilyev kmans...@gmail.com wrote:
   OK. Try calling Toast from the UI thread. You can use Handler for
 this.
   09.04.2011 14:10 пользователь ABSOLUT davidt...@gmail.com
 написал:
 
Yes I'm sure.
 
I have:
 
public void wakeonLan (){
..

while (pruebaPing(maquina)){
//MIENTR=AS NO RESPONDA A PING. DORMIMOS 6 SEGUNDOS EL
PROCESO
 
Thread.sleep(6000);
contadorDormido=contadorDormido+6;
Log.d(PRUEBA, No responde a ping despues de mandar el
paquete magico en... + contadorDormido);
Toast.makeText(getApplicationContext(), No responde a
ping despues de mandar el paquete magico en... + contadorDormido,
Toast.LENGTH_SHORT).show();
Toast.makeText(this, No esponde a ping despues de
mandar el paquete magico en... + contadorDormido,
Toast.LENGTH_SHORT).show();
Toast.makeText(ssh.this.getApplicationContext(), No
responde a ping despues de mandar el paquete magico en... +
contadorDormido, Toast.LENGTH_SHORT).show();

 
And I can see the logcat
 
Please any help?
Many thanks
 
On 9 abr, 11:49, Kostya Vasilyev kmans...@gmail.com wrote:
Are you sure this code actually runs, and calls Toast? Add logcat
   printouts
just before Toast to make sure.
09.04.2011 13:13 пользователь David Tabernero 
 davidt...@gmail.com
написал:
 
 Hi,
 
 I can't display Toast in my application:
 
 I have this code but nothing happens. Any help please?
 
 Many thanks and sorry for my english!
 
 
 
 public void wakeonLan (){
 
 try {
 while (pruebaPing(maquina)){
 Toast.makeText(ssh.this, No responde a ping despues de
 mandar el paquete magico en... + contadorDormido,
 Toast.LENGTH_SHORT).show();
 Toast.makeText(getApplicationContext(), No responde a ping
 despues de mandar el paquete magico en... + contadorDormido,
 Toast.LENGTH_SHORT).show();
 
 .
 
 --
 You received this message because you are subscribed to the
 Google
 Groups Android Developers group.
 To post to this group, send email to
 
   android-developers@googlegroups.com
 
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
 
--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to
 
  android-developers@googlegroups.com
 
To unsubscribe from this group, send email to

Re: [android-developers] Re: help: dont display Toast

2011-04-09 Thread Kostya Vasilyev
Your code, as far as I can tell, runs inside onCreate. Android UI framework
is designed so that it expects callbacks like onCreate and others to return
control to Android within a reasonable amount of time.

Your code prevents Android from doing things in the UI, including showing
toasts (or dialogs), because it ties up the UI thread with your work
function.

Study Application fundamentals in the SDK documentation, specifically
information about threads, it does a good job at explaining this.

To run networking code, create a background thread. An easy way to do it is
to use AsyncTask, a generic class provided by the Android framework.
09.04.2011 20:06 пользователь ABSOLUT davidt...@gmail.com написал:
 I dont understand what do you say Kostya
 I've installed the app in the devices but the Toast doesnt shows.
 The complete Oncreate is:

 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 Log.d(PRUEBA, COMENZAMOS EL PROGRAMA);

 // Toast.makeText(ssh.this, ,
 Toast.LENGTH_SHORT).show();

 InetAddress pp;
 InetAddress direccionMaquinon;

 if (pruebaPing(221.221.221.2)){
 Log.d(PRUEBA,No llega despues de comprobar el primer ping.
 Hay que mandar paquete);
 Toast.makeText(this, ,
 Toast.LENGTH_SHORT).show();

 wakeonLan();
 Toast.makeText(this, ,
 Toast.LENGTH_SHORT).show();
 mandarSsh();
 }else{
 Log.d(PRUEBA,slllega);
 mandarSsh();
 }
 }
 public void wakeonLan (){


 try {
 Toast.makeText(this, Nsdfsdfdsfd paquete magico en...,
 Toast.LENGTH_LONG).show();


 final int PORT = 9;
 String ipStr = 221.x
 ...
 ...



 On 9 abr, 17:24, Kostya Vasilyev kmans...@gmail.com wrote:
 The toast will only show after your code returns from onCreate, which it
 should.
 09.04.2011 19:01 пользователь ABSOLUT davidt...@gmail.com написал:

  Hi again,
  I can't understand nothing.
  I'm trying to execute a simple toast when the activity create but
  doenn't show anything:

  code:

  public class ssh extends Activity {
  /** Called when the activity is first created. */
  public static final int PORT = 9;

  @Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  Log.d(PRUEBA, COMENZAMOS EL PROGRAMA);

  Toast.makeText(ssh.this, ,
  Toast.LENGTH_SHORT).show();
  ...
  

  On 9 abr, 12:26, Kostya Vasilyev kmans...@gmail.com wrote:
  OK. Try calling Toast from the UI thread. You can use Handler for
this.
  09.04.2011 14:10 пользователь ABSOLUT davidt...@gmail.com написал:

   Yes I'm sure.

   I have:

   public void wakeonLan (){
   ..
   
   while (pruebaPing(maquina)){
   //MIENTR=AS NO RESPONDA A PING. DORMIMOS 6 SEGUNDOS EL
   PROCESO

   Thread.sleep(6000);
   contadorDormido=contadorDormido+6;
   Log.d(PRUEBA, No responde a ping despues de mandar el
   paquete magico en... + contadorDormido);
   Toast.makeText(getApplicationContext(), No responde a
   ping despues de mandar el paquete magico en... + contadorDormido,
   Toast.LENGTH_SHORT).show();
   Toast.makeText(this, No esponde a ping despues de
   mandar el paquete magico en... + contadorDormido,
   Toast.LENGTH_SHORT).show();
   Toast.makeText(ssh.this.getApplicationContext(), No
   responde a ping despues de mandar el paquete magico en... +
   contadorDormido, Toast.LENGTH_SHORT).show();
   

   And I can see the logcat

   Please any help?
   Many thanks

   On 9 abr, 11:49, Kostya Vasilyev kmans...@gmail.com wrote:
   Are you sure this code actually runs, and calls Toast? Add logcat
  printouts
   just before Toast to make sure.
   09.04.2011 13:13 пользователь David Tabernero 
davidt...@gmail.com
   написал:

Hi,

I can't display Toast in my application:

I have this code but nothing happens. Any help please?

Many thanks and sorry for my english!



public void wakeonLan (){

try {
while (pruebaPing(maquina)){
Toast.makeText(ssh.this, No responde a ping despues de
mandar el paquete magico en... + contadorDormido,
Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), No responde a ping
despues de mandar el paquete magico en... + contadorDormido,
Toast.LENGTH_SHORT).show();

.

--
You received this message because you are subscribed to the
Google
Groups Android Developers group.
To post to this group, send email to

  android-developers@googlegroups.com

To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
   http://groups.google.com/group/android-developers?hl=en

   --
   You received this message because you are subscribed to the Google
 

Re: [android-developers] Re: help: dont display Toast

2011-04-09 Thread Kostya Vasilyev
And does that work? :)
09.04.2011 22:35 пользователь ABSOLUT davidt...@gmail.com написал:
 Many thanks,
 I'm using now Asyntask and I'm using Toast in PreExecute and
 PostExecute methods.




 On 9 abr, 18:51, Kostya Vasilyev kmans...@gmail.com wrote:
 Your code, as far as I can tell, runs inside onCreate. Android UI
framework
 is designed so that it expects callbacks like onCreate and others to
return
 control to Android within a reasonable amount of time.

 Your code prevents Android from doing things in the UI, including showing
 toasts (or dialogs), because it ties up the UI thread with your work
 function.

 Study Application fundamentals in the SDK documentation, specifically
 information about threads, it does a good job at explaining this.

 To run networking code, create a background thread. An easy way to do it
is
 to use AsyncTask, a generic class provided by the Android framework.
 09.04.2011 20:06 пользователь ABSOLUT davidt...@gmail.com написал:

  I dont understand what do you say Kostya
  I've installed the app in the devices but the Toast doesnt shows.
  The complete Oncreate is:

  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  Log.d(PRUEBA, COMENZAMOS EL PROGRAMA);

  // Toast.makeText(ssh.this, ,
  Toast.LENGTH_SHORT).show();

  InetAddress pp;
  InetAddress direccionMaquinon;

  if (pruebaPing(221.221.221.2)){
  Log.d(PRUEBA,No llega despues de comprobar el primer ping.
  Hay que mandar paquete);
  Toast.makeText(this, ,
  Toast.LENGTH_SHORT).show();

  wakeonLan();
  Toast.makeText(this, ,
  Toast.LENGTH_SHORT).show();
  mandarSsh();
  }else{
  Log.d(PRUEBA,slllega);
  mandarSsh();
  }
  }
  public void wakeonLan (){

  try {
  Toast.makeText(this, Nsdfsdfdsfd paquete magico en...,
  Toast.LENGTH_LONG).show();

  final int PORT = 9;
  String ipStr = 221.x
  ...
  ...

  On 9 abr, 17:24, Kostya Vasilyev kmans...@gmail.com wrote:
  The toast will only show after your code returns from onCreate, which
it
  should.
  09.04.2011 19:01 пользователь ABSOLUT davidt...@gmail.com написал:

   Hi again,
   I can't understand nothing.
   I'm trying to execute a simple toast when the activity create but
   doenn't show anything:

   code:

   public class ssh extends Activity {
   /** Called when the activity is first created. */
   public static final int PORT = 9;

   @Override
   public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   Log.d(PRUEBA, COMENZAMOS EL PROGRAMA);

   Toast.makeText(ssh.this, ,
   Toast.LENGTH_SHORT).show();
   ...
   

   On 9 abr, 12:26, Kostya Vasilyev kmans...@gmail.com wrote:
   OK. Try calling Toast from the UI thread. You can use Handler for
 this.
   09.04.2011 14:10 пользователь ABSOLUT davidt...@gmail.com
написал:

Yes I'm sure.

I have:

public void wakeonLan (){
..

while (pruebaPing(maquina)){
//MIENTR=AS NO RESPONDA A PING. DORMIMOS 6 SEGUNDOS EL
PROCESO

Thread.sleep(6000);
contadorDormido=contadorDormido+6;
Log.d(PRUEBA, No responde a ping despues de mandar el
paquete magico en... + contadorDormido);
Toast.makeText(getApplicationContext(), No responde a
ping despues de mandar el paquete magico en... +
contadorDormido,
Toast.LENGTH_SHORT).show();
Toast.makeText(this, No esponde a ping despues de
mandar el paquete magico en... + contadorDormido,
Toast.LENGTH_SHORT).show();
Toast.makeText(ssh.this.getApplicationContext(), No
responde a ping despues de mandar el paquete magico en... +
contadorDormido, Toast.LENGTH_SHORT).show();


And I can see the logcat

Please any help?
Many thanks

On 9 abr, 11:49, Kostya Vasilyev kmans...@gmail.com wrote:
Are you sure this code actually runs, and calls Toast? Add
logcat
   printouts
just before Toast to make sure.
09.04.2011 13:13 пользователь David Tabernero 

 davidt...@gmail.com

написал:

 Hi,

 I can't display Toast in my application:

 I have this code but nothing happens. Any help please?

 Many thanks and sorry for my english!

 
 
 public void wakeonLan (){

 try {
 while (pruebaPing(maquina)){
 Toast.makeText(ssh.this, No responde a ping despues de
 mandar el paquete magico en... + contadorDormido,
 Toast.LENGTH_SHORT).show();
 Toast.makeText(getApplicationContext(), No responde a ping
 despues de mandar el paquete magico en... + contadorDormido,
 Toast.LENGTH_SHORT).show();
 
 .

 --
 You received this message because you are subscribed to the
 Google
 Groups Android