• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps startActivity didn't work

RaoulH

Newbie
Hello,

in my app, i use the method startActivity to launch a new activity.
The code that i use:
Java:
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:
06-29 17:17:27.887 22615-22615/com.lekonquer.xxx.xxxxW/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@84263c1
06-29 17:17:27.918 22615-22615/com.lekonquer.xxx.xxxx I/DecorView: It non-support bigbang
06-29 17:17:27.922 22615-22615/com.lekonquer.xxx.xxxxI/PhoneWindow: isNeedChangeNaviBarColor taskInfo: [android.app.ActivityManager$RunningTaskInfo@8eba3f2] size: 1
06-29 17:17:27.922 22615-22615/com.lekonquer.xxx.xxxx I/PhoneWindow: isAPPNeedChange pkgName: com.lekonquer.xxx.xxxx needKeep: false
06-29 17:17:27.922 22615-22615/com.lekonquer.xxx.xxxx I/PhoneWindow: isNeedChangeNaviBarColor false
06-29 17:17:27.922 22615-22615/com.lekonquer.xxx.xxxx I/PhoneWindow: generateLayout mNavigationBarColor: ff000000
06-29 17:17:27.922 22615-22615/com.lekonquer.xxx.xxxx I/PhoneWindow: generateLayout isLightNavi false, Visibility: 0
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
 
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()
 
Hello,
@LV426, thank you for your reply. It's very strange,
I will try to run in debug mode.
This is the entire code:

Java:
package com.lekonquer.raoul.geoconnect;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.lekonquer.raoul.IMessage;
import com.lekonquer.raoul.connectdb.SendSMS;

import com.mobsandgeeks.saripaar.ValidationError;
import com.mobsandgeeks.saripaar.Validator;
import com.mobsandgeeks.saripaar.annotation.ConfirmPassword;
import com.mobsandgeeks.saripaar.annotation.Email;
import com.mobsandgeeks.saripaar.annotation.NotEmpty;
import com.mobsandgeeks.saripaar.annotation.Password;
import com.mobsandgeeks.saripaar.annotation.Pattern;

import org.json.JSONArray;

import java.util.List;
import java.util.Random;

/**
* Created by user on .
*/

public class SigninActivity extends AppCompatActivity implements Validator.ValidationListener, IMessage {

    @NotEmpty
    private EditText editTextName;

    private EditText editTextFirstName;

    @NotEmpty
    @Email
    private EditText editTextEmail;

    @NotEmpty
    @Pattern(regex = "^[2]\\d{4}\\d{4}$")
    private EditText editPhoneNumber;

    @NotEmpty
    @Password
    private EditText editTextPassword;

    @NotEmpty
    @ConfirmPassword
    private EditText editTextConfirmPass;

    private Validator validator;

    private static final String INSERT_NEW_CODE = "https://xxxxx/yyy.php";

    private JSONArray fOffersResult = null;

    private SendSM fSendSM = new SendSM();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_signup);
        initViews();
        validator = new Validator(this);
        validator.setValidationListener(this);
    }

    private void initViews(){
        editTextName = (EditText) findViewById(R.id.textView);
        editTextFirstName = (EditText) findViewById(R.id.textView5);
        editTextEmail = (EditText) findViewById(R.id.textView7);
        editPhoneNumber = (EditText) findViewById(R.id.textView6);
        editTextPassword = (EditText) findViewById(R.id.textPassword);
        editTextConfirmPass = (EditText) findViewById(R.id.textConfPassword);
    }

    public void signIn(View view) {
        Log.i("test", "in button signin");
        //validator.validate();
        if(!SigninActivity.this.isFinishing()){
            startActivity(new Intent(SigninActivity.this, ConfirmPhoneNumber.class));
        }

       
    }
    @Override
    public void onValidationSucceeded() {
        Toast.makeText(this, "We got it right!", Toast.LENGTH_SHORT).show();
        Log.w("validateSucceeded ", "before send sms");

        //Gets the code
        Random r = new Random();
        int codetouse = r.nextInt(100000);
        Log.w("code", ""+codetouse);
        Toast.makeText(this, "Code to use:"+codetouse, Toast.LENGTH_SHORT).show();
       
    }

    @Override
    public void onValidationFailed(List<ValidationError> errors) {
        for (ValidationError error : errors) {
            View view = error.getView();
            String message = error.getCollatedErrorMessage(this);
            // Display error messages
            if (view instanceof EditText) {
                ((EditText) view).setError(message);
            } else {
                Toast.makeText(this, message, Toast.LENGTH_LONG).show();
            }
        }
    }

    @Override
    public void getOffersResultPostExecute(int pReturnStatus, String pCalledUrl, JSONArray pOffers) {

       
    }
}
 
Hello,
finally, after many hours spent to understand what's wrong. I finally found the mistake. When i called
Code:
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
 
Last edited:
In my case, This occurred when i was trying to pass a really long JSON string through intent extras. From what I can infer , passing a really large value through the extra bundle might lead to memory issues when starting the new intent. Try using shared preferences or serializable objects to share large stuff between activities

Hope that helped!
 
Back
Top Bottom