The_Hilz
The_Hilz

Reputation: 33

Unable to start new Activity on button click using Intent,Logcat shows no errors

I am trying to start an activity on button click,Current activity has 3 buttons,when a user clicks login button i need to open Login activity,this is my code

Current Activity:

import com.firebase.ui.auth.AuthUI;

import com.google.firebase.auth.FirebaseAuth;

public class Startup extends AppCompatActivity implements View.OnClickListener{
    Intent intent;

    Button login;
    Button signin;
    Button fb;
    private  static final int RC_SIGN_IN= 0;

    private FirebaseAuth auth;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_startup);
        auth= FirebaseAuth.getInstance();

        login = (Button)findViewById(R.id.btlogin);
        signin = (Button)findViewById(R.id.btsignin);
        fb = (Button)findViewById(R.id.fb_con);


        signin.setOnClickListener(this);
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                intent = new Intent(Startup.this, Login.class);
                startActivity(intent);



            }
        });
        fb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (auth.getCurrentUser()!= null){
                    Intent intent = new Intent(Startup.this, Main2Activity.class);
                    startActivity(intent);
                    finish();

                }else {

                    startActivityForResult(AuthUI.getInstance().createSignInIntentBuilder().setProviders(
                            AuthUI.GOOGLE_PROVIDER)
                            .build(),RC_SIGN_IN
                    );

                }

            }


        });




    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == RC_SIGN_IN){
            if (resultCode==RESULT_OK){

                Log.d("Auth",auth.getCurrentUser().getEmail());
                Log.d("Auth Name",auth.getCurrentUser().getDisplayName());
                Intent intent = new Intent(this, Main2Activity.class);
                startActivity(intent);
                finish();


            }
            else {

                Log.d("Auth","Not Authenticated");

            }
        }
    }

    @Override
    public void onClick(View v){
        Intent intent = new Intent(this, Main2Activity.class);
        startActivity(intent);
        finish();
    }
}

The Loginn class doesent start and app crashes with no Real error in Logcat.

Updated Manifest My manfest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="hilz.hellogreen">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:roundIcon="@drawable/icon"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".SplashActivity"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Main2Activity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">

            <!-- <intent-filter> -->
            <!-- <action android:name="android.intent.action.MAIN" /> -->


            <!-- <category android:name="android.intent.category.LAUNCHER" /> -->
            <!-- </intent-filter> -->
        </activity>
        <activity
            android:name=".Startup"
            android:label="Hello Green"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity android:name=".Orders"></activity>
        <activity android:name=".Login"></activity>
    </application>

</manifest>

UPDATE: I now notice this error in Logcat:

 E/SmartFaceManager: Listener does not implements SmartFaceInfoListener2

Upvotes: 0

Views: 174

Answers (2)

The_Hilz
The_Hilz

Reputation: 33

So this hapenned after i refracted a number of classes,I got a recent clean copy from repository and tried again.Apparently this was happening because Appcompat couldnt support the themes features,Adding a NoActionBar property to the theme solved the problem

Upvotes: 0

Sylvain GIROD
Sylvain GIROD

Reputation: 856

There is typo in your code.

In the java class, you refer to Loginn.class and in your manifest .Login which are not the same.

Change Loginn.class into Login.class (which seems to be the correct spelling) and it should work.

Upvotes: 2

Related Questions