1. Are you ready for the Galaxy S20? Here is everything we know so far!

startActivity didn't work

Discussion in 'Android Development' started by RaoulH, Jun 29, 2019.

  1. RaoulH

    RaoulH Newbie
    Thread Starter

    Hello,

    in my app, i use the method startActivity to launch a new activity.
    The code that i use:
    Code (Java):
    1. startActivity(new Intent(this, SigninActivity.class));
    but when the startActivity is called, the new activity wasn't launch, it relaunch the current activity.
    In LogCat, i found this:
    Code (Text):
    1. 06-29 17:17:27.887 22615-22615/com.lekonquer.xxx.xxxxW/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@84263c1
    2. 06-29 17:17:27.918 22615-22615/com.lekonquer.xxx.xxxx I/DecorView: It non-support bigbang
    3. 06-29 17:17:27.922 22615-22615/com.lekonquer.xxx.xxxxI/PhoneWindow: isNeedChangeNaviBarColor taskInfo: [android.app.ActivityManager$RunningTaskInfo@8eba3f2] size: 1
    4. 06-29 17:17:27.922 22615-22615/com.lekonquer.xxx.xxxx I/PhoneWindow: isAPPNeedChange pkgName: com.lekonquer.xxx.xxxx needKeep: false
    5. 06-29 17:17:27.922 22615-22615/com.lekonquer.xxx.xxxx I/PhoneWindow: isNeedChangeNaviBarColor false
    6. 06-29 17:17:27.922 22615-22615/com.lekonquer.xxx.xxxx I/PhoneWindow: generateLayout mNavigationBarColor: ff000000
    7. 06-29 17:17:27.922 22615-22615/com.lekonquer.xxx.xxxx I/PhoneWindow: generateLayout isLightNavi false, Visibility: 0
    8. 06-29 17:17:28.139 22615-22615/com.lekonquer.xxx.xxxx I/AssistStructure: Flattened final assist data: 3072 bytes, containing 1 windows, 9 views
    Please could you have an idea of the issue?

    Thanks

     


  2. Best Answer:
    Post #10 by RaoulH, Jul 19, 2019 (1 points)
  3. Deleted User

    Deleted User Guest

    That's a strange problem.
    But we really need to see a bit more code around that line, to establish the context.
    Seeing the code for SigninActivity class would be useful.
    The logcat content doesn't really shed any light on the problem.

    Another thing you could try is running your app in debug mode and setting a break point in onCreate()
     
  4. RaoulH

    RaoulH Newbie
    Thread Starter

    Hello,
    @LV426, thank you for your reply. It's very strange,
    I will try to run in debug mode.
    This is the entire code:

    Code (Java):
    1. package com.lekonquer.raoul.geoconnect;
    2.  
    3. import android.content.Intent;
    4. import android.os.Bundle;
    5. import android.support.v7.app.AppCompatActivity;
    6. import android.util.Log;
    7. import android.view.View;
    8. import android.widget.EditText;
    9. import android.widget.Toast;
    10.  
    11. import com.lekonquer.raoul.IMessage;
    12. import com.lekonquer.raoul.connectdb.SendSMS;
    13.  
    14. import com.mobsandgeeks.saripaar.ValidationError;
    15. import com.mobsandgeeks.saripaar.Validator;
    16. import com.mobsandgeeks.saripaar.annotation.ConfirmPassword;
    17. import com.mobsandgeeks.saripaar.annotation.Email;
    18. import com.mobsandgeeks.saripaar.annotation.NotEmpty;
    19. import com.mobsandgeeks.saripaar.annotation.Password;
    20. import com.mobsandgeeks.saripaar.annotation.Pattern;
    21.  
    22. import org.json.JSONArray;
    23.  
    24. import java.util.List;
    25. import java.util.Random;
    26.  
    27. /**
    28. * Created by user on .
    29. */
    30.  
    31. public class SigninActivity extends AppCompatActivity implements Validator.ValidationListener, IMessage {
    32.  
    33.     @NotEmpty
    34.     private EditText editTextName;
    35.  
    36.     private EditText editTextFirstName;
    37.  
    38.     @NotEmpty
    39.     @Email
    40.     private EditText editTextEmail;
    41.  
    42.     @NotEmpty
    43.     @Pattern(regex = "^[2]\\d{4}\\d{4}$")
    44.     private EditText editPhoneNumber;
    45.  
    46.     @NotEmpty
    47.     @Password
    48.     private EditText editTextPassword;
    49.  
    50.     @NotEmpty
    51.     @ConfirmPassword
    52.     private EditText editTextConfirmPass;
    53.  
    54.     private Validator validator;
    55.  
    56.     private static final String INSERT_NEW_CODE = "https://xxxxx/yyy.php";
    57.  
    58.     private JSONArray fOffersResult = null;
    59.  
    60.     private SendSM fSendSM = new SendSM();
    61.  
    62.     @Override
    63.     protected void onCreate(Bundle savedInstanceState) {
    64.         super.onCreate(savedInstanceState);
    65.         setContentView(R.layout.activity_signup);
    66.         initViews();
    67.         validator = new Validator(this);
    68.         validator.setValidationListener(this);
    69.     }
    70.  
    71.     private void initViews(){
    72.         editTextName = (EditText) findViewById(R.id.textView);
    73.         editTextFirstName = (EditText) findViewById(R.id.textView5);
    74.         editTextEmail = (EditText) findViewById(R.id.textView7);
    75.         editPhoneNumber = (EditText) findViewById(R.id.textView6);
    76.         editTextPassword = (EditText) findViewById(R.id.textPassword);
    77.         editTextConfirmPass = (EditText) findViewById(R.id.textConfPassword);
    78.     }
    79.  
    80.     public void signIn(View view) {
    81.         Log.i("test", "in button signin");
    82.         //validator.validate();
    83.         if(!SigninActivity.this.isFinishing()){
    84.             startActivity(new Intent(SigninActivity.this, ConfirmPhoneNumber.class));
    85.         }
    86.  
    87.        
    88.     }
    89.     @Override
    90.     public void onValidationSucceeded() {
    91.         Toast.makeText(this, "We got it right!", Toast.LENGTH_SHORT).show();
    92.         Log.w("validateSucceeded ", "before send sms");
    93.  
    94.         //Gets the code
    95.         Random r = new Random();
    96.         int codetouse = r.nextInt(100000);
    97.         Log.w("code", ""+codetouse);
    98.         Toast.makeText(this, "Code to use:"+codetouse, Toast.LENGTH_SHORT).show();
    99.        
    100.     }
    101.  
    102.     @Override
    103.     public void onValidationFailed(List<ValidationError> errors) {
    104.         for (ValidationError error : errors) {
    105.             View view = error.getView();
    106.             String message = error.getCollatedErrorMessage(this);
    107.             // Display error messages
    108.             if (view instanceof EditText) {
    109.                 ((EditText) view).setError(message);
    110.             } else {
    111.                 Toast.makeText(this, message, Toast.LENGTH_LONG).show();
    112.             }
    113.         }
    114.     }
    115.  
    116.     @Override
    117.     public void getOffersResultPostExecute(int pReturnStatus, String pCalledUrl, JSONArray pOffers) {
    118.  
    119.        
    120.     }
    121. }
    122.  
     
  5. wseng92

    wseng92 Android Enthusiast

    Did your app crashed ?
     
  6. Cao Van Thanh

    Cao Van Thanh Member

    Did you define your activity in manifest.xml?
     
  7. RaoulH

    RaoulH Newbie
    Thread Starter

    Yes i defined it:
    Code (Text):
    1. .........
    2. <activity
    3.             android:name=".SigninActivity"
    4.             android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen" />
    5. ......
     
  8. RaoulH

    RaoulH Newbie
    Thread Starter

    No
     
  9. wseng92

    wseng92 Android Enthusiast

    Are you sure it running the if block?
     
    Deleted User likes this.
  10. Deleted User

    Deleted User Guest

    There's only one way to find out... Breakpoint it! ;)
     
    wseng92 likes this.
  11. RaoulH

    RaoulH Newbie
    Thread Starter

    Hello,
    finally, after many hours spent to understand what's wrong. I finally found the mistake. When i called
    Code (Text):
    1. setContentView(R.layout.activity_xxxxxxx);
    i used the same layout for the 2 activities and that it is not good.
    When i changed that it is ok.
    Many thanks for your replies
     
    #10 RaoulH, Jul 19, 2019
    Last edited: Jul 19, 2019
Loading...

Share This Page

Loading...