Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – When I run my application on my Android Phone from Android Studio, it shows blank screen

Posted on November 11, 2022 By

Solution 1 :

You forgot to set setContentView()

You should set like this:

setContentView(binding.getRoot());

This should work perfectly.

Solution 2 :

hare your SignUpActivity you forgot to set ContentView. that’s why your screen is blank. You need to do something like this

public class SignUpActivity extends AppCompatActivity {

    ActivitySignUpBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivitySignUpBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
    }
}

Problem :

I am building a Chatting App and I am stuck at Sign Up because when I run my application, it shows a blank screen.

By the way, I am using binding.

And when I use this code:

public class SignUpActivity extends AppCompatActivity {

    ActivitySignUpBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivitySignUpBinding.inflate(getLayoutInflater());
        binding.getRoot();
    }
}

It shows a blank screen.

And when I use this code:

public class SignUpActivity extends AppCompatActivity {

    ActivitySignUpBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sign_up);
    }
}

It shows an error that: NewAge Chat keeps stopping.

activity_sign_up.xml code:

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns_android="http://schemas.android.com/apk/res/android"
        xmlns_app="http://schemas.android.com/apk/res-auto"
        xmlns_tools="http://schemas.android.com/tools"
        android_layout_width="match_parent"
        android_layout_height="match_parent"
        tools_context=".SignUpActivity"
        android_orientation="vertical"
        android_background="@drawable/w1"
        android_gravity="center">

    <ImageView
        android_layout_height="100dp"
        android_layout_width="100dp"
        android_id="@+id/logo"
        android_src="@drawable/ic_launcher_favicon"/>

    <EditText
        android_id="@+id/txtUsername"
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_hint="Username"
        android_textColor="@color/white"
        android_textColorHint="@color/chatbackground"
        android_layout_marginTop="15dp"
        android_layout_marginBottom="10dp"
        android_ems="10"
        android_inputType="textPersonName"
        android_padding="9dp"
        android_textSize="20sp"/>

    <EditText
        android_id="@+id/txtEmail"
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_hint="Email"
        android_textColor="@color/white"
        android_textColorHint="@color/chatbackground"
        android_layout_marginBottom="10dp"
        android_ems="10"
        android_inputType="textEmailAddress"
        android_padding="9dp"
        android_textSize="20sp"/>

    <EditText
        android_id="@+id/txtPassword"
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_hint="Password"
        android_textColor="@color/white"
        android_textColorHint="@color/chatbackground"
        android_layout_marginBottom="10dp"
        android_ems="10"
        android_inputType="textPassword"
        android_padding="9dp"
        android_textSize="20sp"/>

    <TextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_id="@+id/alreadyHaveAccount"
        android_layout_gravity="right"
        android_text="Already Have An Account"
        android_textColor="@color/white"
        android_textStyle="bold"
        android_textSize="18sp"/>

    <Button
        android_layout_width="150dp"
        android_layout_height="70dp"
        android_text="Sign Up"
        android_textSize="20sp"
        android_textAllCaps="false"
        android_id="@+id/btnSignUp"/>

    <LinearLayout
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_gravity="center">
        <Button
            android_layout_width="170dp"
            android_layout_height="70dp"
            android_id="@+id/btnGoogle"
            android_text="Google"
            android_textAllCaps="false"
            android_backgroundTint="@color/white"
            android_textColor="@color/black"
            android_textSize="20sp"
            android_paddingTop="5dp"
            android_paddingBottom="7dp"
            android_paddingLeft="20dp"
            android_paddingRight="20dp"
            android_layout_marginRight="40sp"/>

        <Button
            android_layout_width="170dp"
            android_layout_height="70dp"
            android_id="@+id/btnFacebook"
            android_text="Facebook"
            android_textAllCaps="false"
            android_backgroundTint="@color/fb_color"
            android_textColor="@color/black"
            android_textSize="20sp"
            android_paddingTop="5dp"
            android_paddingBottom="7dp"
            android_paddingLeft="20dp"
            android_paddingRight="20dp"/>
    </LinearLayout>

    <TextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_id="@+id/signUpPhone"
        android_text="Sign Up with Phone"
        android_textSize="25sp"
        android_textColor="@color/white"
        android_paddingTop="25dp"
        android_textStyle="bold"/>

</LinearLayout>

SignUpActivity.java code:

package com.agrim.newagechat;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.agrim.newagechat.databinding.ActivitySignUpBinding;

public class SignUpActivity extends AppCompatActivity {

    ActivitySignUpBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivitySignUpBinding.inflate(getLayoutInflater());
        binding.getRoot();

        getSupportActionBar().hide();

        binding.alreadyHaveAccount.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SignUpActivity.this, SignInActivity.class);
                startActivity(intent);
            }
        });
    }
}

AndroidManifest.xml code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns_android="http://schemas.android.com/apk/res/android"
    xmlns_tools="http://schemas.android.com/tools"
    package="com.agrim.newagechat">

    <application
        android_allowBackup="true"
        android_dataExtractionRules="@xml/data_extraction_rules"
        android_fullBackupContent="@xml/backup_rules"
        android_icon="@drawable/ic_launcher_favicon"
        android_label="@string/app_name"
        android_roundIcon="@drawable/ic_launcher_favicon"
        android_supportsRtl="true"
        android_theme="@style/Theme.NewAgeChat"
        tools_targetApi="31">
        <activity
            android_name=".SignUpActivity"
            android_exported="true">
            <intent-filter>
                <action android_name="android.intent.action.MAIN" />

                <category android_name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android_name=".MainActivity"
            android_exported="false"/>
    </application>

</manifest>

I have setted the <intent-filter></intent-filter> also…

READ  [FIXED] android - How to make named import be the default behavior when importing from XML?
Powered by Inline Related Posts

Comments

Comment posted by Agrim Singh

Can you also tell me why it says NewAge Chat keeps stopping when I set: setContentView(R.layout.activity_sign_up)

Comment posted by Abdullah Jubayer

maybe you do something wrong in your theme.xml or any other file. can you share the logcat?

Comment posted by Agrim Singh

I have changed this:

Comment posted by Abdullah Jubayer

it’s look like ok. please share your crush log

Android Tags:android, android-studio, java, xml

Post navigation

Previous Post: [FIXED] Unable to connect Firebase in Android Emulator for Flutter Project
Next Post: [FIXED] android – Highlight only one Card in Compose through selection

Related Posts

[FIXED] java – Location isalways null Android
[FIXED] java – startactivity creates two instances Android
[FIXED] java – Android: How can I add Google map to a ViewPager? Android
[FIXED] uri – Image compression in bitmap and uploading to server in android Q Android
[FIXED] java – Android Fragment Error: No view found for id 0x7f08009e (com.example.myapplication:id/preferenceFragment) for fragment Android
[FIXED] Android Compose create shake animation Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What are the main features of Islamic education?
  • Is the Jeep 4xe worth it?
  • How does the ringer work on cast iron?
  • What is the biggest size interior door?
  • Is blue raspberry an original Jolly Rancher flavor?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme